Skip to content

Commit 441ca1b

Browse files
committed
feat: Generate index.html within path directories
This commit modifies the build script to generate `index.html` files inside directories corresponding to the defined paths in `links.json`. Previously, HTML files were generated directly as `[path].html`. This change ensures that URLs like `/foo` and `/foo/` both correctly resolve to `/foo/index.html`, preventing 404 errors due to trailing slash inconsistencies.
1 parent 1085339 commit 441ca1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ links.forEach(({ paths, url, title, description }) => {
3737
<p>正在前往 <a href="${url}">${title}</a></p>
3838
</body>
3939
</html>`;
40-
fs.writeFileSync(`${linkPath}.html`, htmlContent, "utf8");
40+
fs.mkdirSync(linkPath, { recursive: true });
41+
fs.writeFileSync(path.join(linkPath, "index.html"), htmlContent, "utf8");
4142
});
4243
});
4344

0 commit comments

Comments
 (0)