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

[Bug report] page links failed in pages that use permalink #1227

Closed
1 task done
meteorlxy opened this issue Jan 25, 2019 · 5 comments
Closed
1 task done

[Bug report] page links failed in pages that use permalink #1227

meteorlxy opened this issue Jan 25, 2019 · 5 comments
Labels
contribution welcome Contributions welcome has workaround Has a workaround topic: docs Used when working with docs type: enhancement Request to enhance an existing feature

Comments

@meteorlxy
Copy link
Member

meteorlxy commented Jan 25, 2019

  • I confirm that this is a issue rather than a question.

Bug report

Version

v1.0.0-alpha.34

Steps to reproduce

docs
├── with-permalink.md
└── target-page.md

One page uses permalink, in which there is a link to the other page.

The other page does not use permalink.

// with-permalink.md
---
permalink: '/foo/bar'
---

[To target page](./target-page.md)

What is expected?

The link url is rendered as '/target-page.html', which points to target-page.md.

What is actually happening?

The link url is rendered as '/foo/bar/target-page.html', which does not exist.

@meteorlxy meteorlxy changed the title [Feature request] convert router link to permalink [Bug report] page links failed in pages that use permalink Jan 29, 2019
@meteorlxy meteorlxy reopened this Jan 29, 2019
@ulivz
Copy link
Member

ulivz commented Jan 29, 2019

It’s truly an issue. but to a certain extent, I don't agree that this is an issue.

Once you set permalink to foo/bar, it means that the file will eventually be generated under foo/bar, since you are using a relative path, it would not be reasonable if you look at the relative path of the build assets.

So there is a workaround: once you used a permalink, you should use absolute paths first. maybe at this time, we need to mark this limit in the documentation.

It is more complicated to resolve the relative path during the build process, and it may also bring a breaking change.


Whatever, this is a issue worth solving, and contribution welcome.

@ulivz ulivz added contribution welcome Contributions welcome topic: docs Used when working with docs type: enhancement Request to enhance an existing feature has workaround Has a workaround and removed contribution welcome Contributions welcome labels Jan 29, 2019
@meteorlxy
Copy link
Member Author

A common situation is in posts of blog. It might be annoying to link to other posts by absolute path.

@ulivz
Copy link
Member

ulivz commented Jan 29, 2019

In the blog lovers I know, it seems that they all use absolute paths, e.g. @egoist. ref.

@meteorlxy
Copy link
Member Author

Oh that makes me thinking about: Why Vuepress allow links end with .md?

I guess it's to be compatible with docs, as many projects just put their docs on github (like lerna).

I'm not so familiar with other tools, but they might not allow *.md link? So users have to write the url themselves.

(Vuepress makes me lazy lol 😅 )

@shigma
Copy link
Collaborator

shigma commented Feb 16, 2019

@meteorlxy We can change the behavior of resolution of relative urls in pages that use permalink.

if (!to.startsWith('/')) {
  to = relPath
    ? url.resolve('/' + relPath, to) // resolve url with the relative path of the file by default
    : ensureBeginningDotSlash(to)    // add a `./` before the url otherwise (previous strategy)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Contributions welcome has workaround Has a workaround topic: docs Used when working with docs type: enhancement Request to enhance an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants