Options for Path-Based Trailing Slash
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
/postsseems to represent a top-level directory for viewing all posts./posts/would be more appropriate.
/posts/category-aalso represents a directory concept./posts/category-a/would be more fitting.
/posts/category-a/hello-worldis a document./posts/category-a/hello-worldis appropriate.
Now, let's discuss navigation formats.
- posts
-
When there is no trailing slash, use
"/posts"- Upward Navigation
- Absolute path:
<a href="/"> - Relative path:
<a href="./">(Is using./for upward navigation a bit strange?)
- Absolute path:
- Downward Navigation
- Absolute path:
<a href="/posts/category-a"> - Relative path:
<a href="./posts/category-a">(Does this seem a bit unusual?)
- Absolute path:
- Upward Navigation
-
When using a trailing slash, use
"/posts/"- Upward Navigation
- Absolute path:
<a href="/posts"> - Relative path:
<a href="../">(This is the correct upward navigation concept.)
- Absolute path:
- Downward Navigation
- Absolute path:
<a href="/posts/category-a/"> - Relative path:
<a href="./category-a/">
- Absolute path:
- Upward Navigation
-
Going a bit deeper:
- posts/category-a
- When there is no trailing slash, use
"/posts/category-a"- Upward Navigation
- Absolute path:
<a href="/posts"> - Relative path:
<a href="./">
- Absolute path:
- Downward Navigation
- Absolute path:
<a href="/posts/category-a/hello-world"> - Relative path:
<a href="./category-a/hello-world"/>
- Absolute path:
- Upward Navigation
- When using a trailing slash, use
"/posts/category-a/"- Upward Navigation
- Absolute path:
<a href="/posts/"> - Relative path:
<a href="../">
- Absolute path:
- Downward Navigation
- Absolute path:
<a href="/posts/category-a/hello-world"> - Relative path:
<a href="./hello-world">
- Absolute path:
- Upward Navigation
- When there is no trailing slash, use
When you want to control screen tree access with relative paths, routes composed of slugs might not allow for precise trailing slashes and may require using ignore (which could potentially cause issues in the future).
Describe the proposed solution
export function trailingSlash({ page }) {
const isDirectory = isDirectory(page.url);
// or
// const isCategoryPage ~~
return isDirectory ? 'always' : 'never';
}
Importance
would make my life easier
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing trailing-slash handling and the proposed trailingSlash({ page }) entry point, including page.url and the suggested isDirectory check. Done means the issue's directory-style and document-style routes can apply different trailing-slash behavior without relying on imprecise slug-based routing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100