Skip to content

Commit

Permalink
fix: correctly determine if array is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
dstaley committed Nov 22, 2023
1 parent 9bc09ab commit d83a013
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-walls-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hashicorp/react-docs-page': patch
---

Fix hasIndexPage calculation
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/docs-page/server/get-paths-from-nav-data.ts
Original file line number Diff line number Diff line change
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.filter((p) => p.length === 0).length > 0
if (!hasIndexPage) pagePathArrays.unshift([])
// Return the array of all page paths
const paths = pagePathArrays.map((p) => ({ params: { [paramId]: p } }))
Expand Down

0 comments on commit d83a013

Please sign in to comment.