Repository navigation
feat: add $build.trailingSlash option - #87
Merged
Merged
Conversation
Some hosts and sites want page URLs without a trailing slash. With $build.trailingSlash: false, each page is an .html file of its path.
Dev served /a from a/index.html with no redirect, so relative URLs resolved differently than on a host. A request with the other trailing slash now redirects to the path of the page file.
A page path with no trailing slash, such as /releases/v1.1.0, lost its last dot part in its Markdown copy: v1.1.md.
The client took /v1.1.0 for a file, and left the link to the browser.
Resolves the $build conflicts with outdir: both options stay, in the types and in the config docs.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Some sites want page URLs without a trailing slash. With
$build.trailingSlash: false, each page is an.htmlfile of its path, so hosts serve it at that URL.Changes
$build.trailingSlash,trueby default, so existing sites do not change. Withfalse:content/index.md/public/index.htmlcontent/about.md/aboutpublic/about.htmlcontent/blog/index.md/blogpublic/blog.htmlcontent/blog/post.md/blog/postpublic/blog/post.htmlA custom
url: /people/drops its slash and writespeople.html.url: /404.htmlstill writes that file.$page.path,$page.url,$pages, sitemaps, and feeds follow.Dev redirects, both ways. A page URL with the other trailing slash gets a
302to the path of its file, with its query. The server picks the redirect from the file that exists, so it needs no config. Before, dev served/afroma/index.htmlwith no redirect, so relative URLs resolved differently than on a host.Fix: Markdown copies of dotted paths.
/releases/v1.1.0gavev1.1.md; it now givesv1.1.0.md.withExtensionreplaces only an.htmlextension.Fix: client links to dotted pages. The client took
/v1.1.0for a file and left the link to the browser. An extension now counts as a file type only when it has a letter.Docs: "Without trailing slashes" in Content, with the Firebase settings and how relative URLs resolve; "Trailing slashes" in Dev server.
Test plan
bun run build,bun test,bunx tsc -p .,bunx tsc -p build,bun docs buildurl.extof a dotted path, and the client check of a dotted pathtrailingSlash: false: every page is a flat file, canonical URLs andllms.txtlinks have no slash, both redirects work, and client navigation stays in one document, back included, with no failed request/configredirects to/config/, and Markdown copies load