21 lines
756 B
JavaScript
21 lines
756 B
JavaScript
module.exports = {
|
|
lang: "en",
|
|
permalink: (data) => {
|
|
// data.page.filePathStem: e.g., "/en/index", "/en/blog/index", "/en/blog/test-post"
|
|
let stem = data.page.filePathStem;
|
|
|
|
// strip the leading /en/ prefix
|
|
if (stem.startsWith("/en/")) {
|
|
stem = stem.replace(/^\/en/, "");
|
|
}
|
|
|
|
// handle index files: If ends with /index, just use stem + /index.html → e.g., /blog/index.html
|
|
// this avoids appending extra /index.html if already ending in /index
|
|
if (stem.endsWith("/index")) {
|
|
return `${stem}.html`; // /blog/index.html
|
|
}
|
|
|
|
// for non-index files: append /index.html for pretty URLs (e.g., /blog/test-post → /blog/test-post/index.html, URL /blog/test-post/)
|
|
return `${stem}/index.html`;
|
|
},
|
|
};
|