-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
docs: document trailingSlash
#2546
Open
BobbieGoede
wants to merge
1
commit into
nuxt-modules:main
Choose a base branch
from
BobbieGoede:docs/document-trailing-slash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7
β0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very sparse. How does that interact with Nuxt's own trailingSlash option? Does it apply to all routes or only those handled by i18n?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the description is lacking, still need to familiarize myself with the routing logic more so I can't answer those questions yet! I figured this is still better than leaving it undocumented π ..
The code it uses is ported from your code in v7 to
vue-i18n-routing
, unless it has changed a lot, you may be better able to answer those questions than I am.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version 7 of this module (for Nuxt 2) doesn't use
vue-i18n-routing
so I'm not familiar with it.I'm a bit surprised that
trailingSlash
option was introduced in context of Nuxt module since IMO this should all be controlled through Nuxt's own setting instead of having two, potentially conflicting, options.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that v7 doesn't use
vue-i18n-routing
, it'svue-i18n-routing
that is based on routing in v7.As far as I can tell, the reason for configuring it in the module is because Nuxt 3 got rid of the
trailingSlash
option. Now it's up to users to create a custom NuxtLink component see: https://nuxt.com/docs/api/components/nuxt-link#overwriting-defaults.Though 3.8 introduced a way to set these NuxtLink defaults in the nuxt config, so we could consider using that config.
Also not sure what happens if users have multiple custom NuxtLink components with different
trailingSlash
settings, when and why this would be used, and how we would handle such edge cases π€·ββοΈ.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Then maybe it's just the way to go and I'm making unnecessary noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you follow the history in blame, you can find this github issue.
nuxt/nuxt#18806
That issue is added by
NuxtLink
to improve SEO for internal links.Follow the issue further and you can find this issue.
nuxt/nuxt#15462
That issue is a proposal to support trailing Slash from Nuxt 2.
https://v2.nuxt.com/docs/configuration-glossary/configuration-router#trailingslash
As you can see from reading the issue, there are several ways we plan to improve trailing Slash, and the trailing Slash support added to
NuxtLink
appears to be one of them.nuxt/nuxt#15462 (comment)
As far as I can understand from reading the issue, Nuxt's policy is to support trailing slashes only at the minimum, and other cases will be handled in userland.
So I think it makes sense to provide a
tranilingSlash
option in nuxt i18n./cc @manniL @danielroe
if you have anything to additional comment, please comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. We leave that up to the user (either viaβΊοΈ
defineNuxtLink
+ options, or via setting defaults for the NuxtLink in thenuxt.config.ts
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what
trailingSlash
would necessarily do in the module (compared to setting it via above mentioned options)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It influences head tags, the generated routes and the way routes are matched and resolved if I understand correctly.
I will be looking into the use of this option, where it is being used and why, and if its usage can be reduced so it won't conflict with the flexible nature of
trailingSlash
prop ofNuxtLink
(if it does). We will probably support setting this option in the future via https://github.com/harlan-zw/nuxt-site-config as well (related #2474).Let's not get distracted, this PR only (barely) documents an old option, motivation behind it is because someone on Discord asked how to enable trailing slashes in this module and enabling this option satisfied their use case.
Just trying to prevent issues as they pour in π ..