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

Force adding of index.html to router links #592

Closed
alex-exerve opened this issue Jun 14, 2018 · 8 comments
Closed

Force adding of index.html to router links #592

alex-exerve opened this issue Jun 14, 2018 · 8 comments

Comments

@alex-exerve
Copy link

Is there an option to have vuepress add index.html to router links instead of using /?

We are creating some documentation that will be available to developers. However, it will be served in a manner that doesn't allow automatically picking up on index.html. Due to the way the router currently is created, the home-link in default-theme will always be equal to config.js::modules.export.base and thus the site logo/title will not link to an index.html

I was looking through the documentation and couldn't find a way to make this happen without ejecting the theme and doing it myself manually.

I can also redo this as a feature request and/or implement it if someone points me in the right direction of where the router creation is.

@meteorlxy
Copy link
Member

From my understanding, adding index.html is the default behavior.

if (/\/$/.test(pagePath)) {
code += `,
{
path: ${JSON.stringify(pagePath + 'index.html')},
redirect: ${JSON.stringify(pagePath)}
}`
}

@alex-exerve
Copy link
Author

I think my main issue is in this line, now that i'm looking at it:

<router-link :to="$localePath" class="home-link">

since it's using the $localePath (which is currently set to /) it will not link to index.html.

Let me try setting my locale and see if that fixes it.

@alex-exerve
Copy link
Author

Okay so yeah, it looks like the issue is that it is using the base/localePath, and won't use the root 'index.html' as the link to the home page in the navbar.

@meteorlxy
Copy link
Member

meteorlxy commented Jun 15, 2018

Oh I catch your point. Currently we redirect /index.html to /. Maybe we should redirect / to /index.html instead?

@alex-exerve
Copy link
Author

Oh I catch your point. Currently we redirect '/index.html' to '/'. Maybe we should redirect '/' to '/index.html' instead?

Or at least give an option in the themeConfig maybe?

@ycmjason
Copy link
Contributor

If @alex-exerve 's environment do not support /, I don't think redirecting / to /index.html could help because the redirection we are doing is on the client side (?)

@alex-exerve
Copy link
Author

True, but it's more about being able to right click a link and copy the url and give it to someone else. At that point it is a redirection issue since new person hasn't been to said thing yet.

This is really not that big of a deal, and was more of an odd thing I ran into in my specific environment. It might be something where it is outside the scope of this project as a whole and I just need to create my own theme to handle this specific issue since it appears to be that one specific link in the navbar.

@ulivz
Copy link
Member

ulivz commented Jun 16, 2018

@alex-exerve

Don't know if the public/_redirects file could help you. refs: vue-router > _redirects


Before adding any new feature to the core, we will consider the complexity brought about by the feature and the actual meaning it produces. for a very rare requirement that can also be done on the user-land, our principle is not to add it to core. sorry but this is our principle.

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

No branches or pull requests

4 participants