Skip to content

Commit

Permalink
fix: correctly determine if array is empty (#1005)
Browse files Browse the repository at this point in the history
* fix: correctly determine if array is empty

* fix: improve readability with some instead of computing length

Co-authored-by: Heat Hamilton <55773810+heatlikeheatwave@users.noreply.github.com>

---------

Co-authored-by: Heat Hamilton <55773810+heatlikeheatwave@users.noreply.github.com>
  • Loading branch information
dstaley and heatlikeheatwave committed Dec 19, 2023
1 parent ccb85e8 commit 6964d98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gold-walls-warn.md
@@ -0,0 +1,5 @@
---
'@hashicorp/react-docs-page': patch
---

Fix hasIndexPage calculation
2 changes: 1 addition & 1 deletion packages/docs-page/server/get-paths-from-nav-data.ts
Expand Up @@ -30,7 +30,7 @@ export function getPathsFromNavData(
const pagePathArrays = getPathArraysFromNodes(navDataResolved)
// Ensure we include an empty array for the "/" index page path
// (may be included in nav-data, eg for Terraform, or may not, eg for all other sites)
const hasIndexPage = pagePathArrays.filter((p) => p == []).length > 0
const hasIndexPage = pagePathArrays.some((p) => p.length === 0)
if (!hasIndexPage) pagePathArrays.unshift([])
// Return the array of all page paths
const paths = pagePathArrays.map((p) => ({ params: { [paramId]: p } }))
Expand Down

1 comment on commit 6964d98

@vercel
Copy link

@vercel vercel bot commented on 6964d98 Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.