Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serving index files #221

Merged
merged 1 commit into from
Apr 26, 2020
Merged

Fix serving index files #221

merged 1 commit into from
Apr 26, 2020

Conversation

n-ari
Copy link
Contributor

@n-ari n-ari commented Apr 26, 2020

Fixed URLs serving index files (index.md, PITCHME.md) in server mode.

Problem

Write presentation files in directories like below:

  • serverRoot/files/index.md : markdown file for Marp
  • serverRoot/files/image.png : image file, used in index.md as ![](image.png)

And run marp-cli as server mode like marp --server serverRoot/.

Then http://localhost:8080/ shows files and directories in serverRoot by serve-index.
In the above settings, a link on that page is http://localhost:8080/files.

When access to that, serverRoot/files/index.md is converted and shown in a browser, but serverRoot/files/image.png is not shown in the presentation because the presentation address is /files and ![](image.png) is linked to /image.png, not /files/image.png.

When access to http://localhost:8080/files/ (with a trailing slash), serverRoot/files/image.png is shown.

For compatibility with other modes, ![](image.png) should be linked to /files/image.png, not /image.png I think.

Solution

To fix this, there are 2 solutions:

  1. Add a trailing slash to the links on the serve-index page.
  2. Redirect to URL with a trailing slash.

In this PR, fixed the template file src/server/index.pug to add a trailing slash to the directory links.

Copy link
Member

@yhatt yhatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's reasonable. Thank you 👍

@yhatt yhatt merged commit ca81250 into marp-team:master Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants