Switch from directory to file format in Astro#2356
Conversation
The "file" format generates "name.html" files instead of default "name/index.html". This would make old links work, even without redirects on Cloudflare level, while still allowing the current link format with no extension. https://docs.astro.build/en/reference/configuration-reference/#buildformat
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
c6870f9 to
951bd1f
Compare
951bd1f to
598b82a
Compare
|
This breaks search results for API pages, which for some reason end with @bjohansebas is there any reason why API docs live as EDIT: Either API docs files must be moved and renamed or the code responsible for uploading pages to Orama must be changed to strip expressjs.com/scripts/orama-documents.mjs Lines 52 to 72 in ec1d037 What should work instead of renaming files (krzysdz/expressjs.com@f1151f6): diff --git a/scripts/orama-documents.mjs b/scripts/orama-documents.mjs
index 0b9a9668..5dd9831a 100644
--- a/scripts/orama-documents.mjs
+++ b/scripts/orama-documents.mjs
@@ -106,7 +106,7 @@ export const getApi = async (lang) => {
const fullPath = join(baseDir, file);
const raw = await readFile(fullPath, 'utf-8');
const { data, content } = matter(raw);
- const pathSegment = relative(baseDir, fullPath).replace(/\.mdx?$/, '');
+ const pathSegment = relative(baseDir, fullPath).replace(/(\/index)?\.mdx?$/, '');
return {
title: data.title ?? basename(file).replace(/\.mdx?$/, ''), |

The "file" format generates
name.htmlfiles instead of defaultname/index.html. This would make old links work, even without redirects on Cloudflare level, while still allowing the current link format with no extension. The only observable difference between current version and this PR is that the URLs no longer end with a/(GitHub/Netlify serve a 301; currently most links don't include the trailing slash, so most internal navigation goes through a redirect - removing this redirect is a small unintentional improvement).References: