Skip to content

Commit de5d099

Browse files
committed
Date prefix blog directories, but strip from permalink urls
1 parent dc62a7b commit de5d099

35 files changed

Lines changed: 22 additions & 191 deletions

File tree

.eleventy.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ const markdownItAnchor = require("markdown-it-anchor");
66

77
module.exports = function (eleventyConfig) {
88
eleventyConfig.addPassthroughCopy("static");
9-
eleventyConfig.addPassthroughCopy("src/blog/**/*.{gif,png,jpg,jpeg,svg}");
9+
eleventyConfig.addPassthroughCopy("src/blog/**/*.{gif,png,jpg,jpeg,svg}", {
10+
mode: "html-relative",
11+
failOnError: true,
12+
});
1013
eleventyConfig.addPassthroughCopy({ "./CNAME": "./CNAME" });
1114
eleventyConfig.addPlugin(syntaxHighlight);
1215
eleventyConfig.addPlugin(eleventyNavigationPlugin);
@@ -33,4 +36,15 @@ module.exports = function (eleventyConfig) {
3336
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
3437
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat("yyyy-LL-dd");
3538
});
39+
40+
/**
41+
* This filter enables me to have directories sorted by date prefixes,
42+
* but exclude those date prefixes from the final URLs.
43+
*/
44+
eleventyConfig.addFilter("stripDatePrefix", (path) => {
45+
// Extract directory name from path and remove date prefix (YYYY-MM-DD-)
46+
const parts = path.split("/");
47+
const dirName = parts[parts.length - 2] || parts[parts.length - 1];
48+
return dirName.replace(/^\d{4}-\d{2}-\d{2}-/, "");
49+
});
3650
};
-2.38 MB
Binary file not shown.
-6.23 KB
Binary file not shown.

src/blog/19-rupert-representations/index.md

Lines changed: 0 additions & 184 deletions
This file was deleted.
-221 KB
Binary file not shown.
-92.2 KB
Binary file not shown.

src/blog/01-generics-arent-as-scary-as-you-think/index.md renamed to src/blog/2021-05-23-generics-arent-as-scary-as-you-think/index.md

File renamed without changes.
File renamed without changes.

src/blog/03-understanding-react-dependency-arrays/index.md renamed to src/blog/2021-06-20-understanding-react-dependency-arrays/index.md

File renamed without changes.

src/blog/04-seeing-through-jsx-to-understand-react-component-types/index.md renamed to src/blog/2021-06-27-seeing-through-jsx-to-understand-react-component-types/index.md

File renamed without changes.

0 commit comments

Comments
 (0)