Skip to content

adding a postbuild step to allow a trailing slash to resolve index pages#268

Merged
heskew merged 1 commit intomainfrom
index-slash
Aug 20, 2025
Merged

adding a postbuild step to allow a trailing slash to resolve index pages#268
heskew merged 1 commit intomainfrom
index-slash

Conversation

@heskew
Copy link
Member

@heskew heskew commented Aug 19, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a post-build step to handle trailing slash URL resolution by copying HTML files to index.html files in corresponding directories. This allows URLs with trailing slashes (e.g., /myPath/) to resolve to the same content as URLs without trailing slashes (e.g., /myPath).

  • Adds a new post-build script that walks through the build directory and creates index.html files
  • Integrates the post-build script into the build command in package.json

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
scripts/postbuild.js New script that creates index.html files from sibling HTML files to support trailing slash URLs
package.json Updates build command to run the post-build script after Docusaurus build

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@heskew
Copy link
Member Author

heskew commented Aug 20, 2025

going to merge now to get the 404 issue resolved in prod

@heskew heskew merged commit 43a44e2 into main Aug 20, 2025
2 checks passed
@heskew heskew deleted the index-slash branch August 20, 2025 13:11

// Walk through all directories recursively
async function* walkDirs(dir) {
const dirents = await fs.readdir(dir, { withFileTypes: true });
Copy link
Member

Choose a reason for hiding this comment

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

https://nodejs.org/docs/latest/api/fs.html#fspromisesreaddirpath-options

FWIW you could use the recursive option for fs.readdir

// Check if there's already an index.html in this directory
const indexPath = path.join(dirPath, 'index.html');
try {
await fs.stat(indexPath);
Copy link
Member

Choose a reason for hiding this comment

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

Should use fs.access() instead if you don't actually care for the result of stat. access is faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

https://docs.harperdb.io/docs/ briefly shows a flash of 404

3 participants