Skip to content

Pager appears when there’s only one page in pages #689

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

Closed
mbostock opened this issue Feb 6, 2024 · 1 comment · Fixed by #1022
Closed

Pager appears when there’s only one page in pages #689

mbostock opened this issue Feb 6, 2024 · 1 comment · Fixed by #1022
Labels
bug Something isn’t working

Comments

@mbostock
Copy link
Member

mbostock commented Feb 6, 2024

E.g.,

export default {
  pages: [
    {name: "Home", path: "/"}
  ]
};

Kind of a degenerate case, but anyway.

@Fil
Copy link
Contributor

Fil commented Mar 8, 2024

This is because the page path is not "normalized", it should be "/index" instead of "/".

We can fix by adding index but it feels wrong?

--- a/src/pager.ts
+++ b/src/pager.ts
@@ -9,7 +9,7 @@ export type PageLink =
 const linkCache = new WeakMap<Config["pages"], Map<string, PageLink>>();

 export function normalizePath(path: string): string {
-  return path.replace(/[?#].*$/, "");
+  return path.replace(/[?#].*$/, "").replace(/\/$/, "/index");
 }

Fil added a commit that referenced this issue Mar 8, 2024
This was referenced Mar 8, 2024
Fil added a commit that referenced this issue Mar 12, 2024
@Fil Fil closed this as completed in #1022 Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants