Skip to content

feat: add last updated date to blog posts #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ module.exports = eleventyConfig => {
value1.concat(value2),
);

eleventyConfig.addFilter("lastUpdated", filepath => {
const relativePath = path.relative("src/content/blog", filepath);
const blogDates = require("./src/_data/blog-dates.json");

return new Date(blogDates[relativePath]);
});

/**
* ***************************************************************************************
* Plugins
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"license": "Apache-2.0",
"scripts": {
"build": "npm-run-all install:playground build:sass build:website build:playground build:minify-images",
"build:init-blog-dates": "node tools/update-blog-dates.js --init",
"build:minify-images": "imagemin '_site/assets/images' --out-dir='_site/assets/images'",
"build:minify-svg": "svgo -r -f ./",
"build:playground": "webpack --mode=production --progress",
Expand Down Expand Up @@ -53,6 +54,10 @@
],
"*.json": "prettier --write",
"*.md": "markdownlint --fix",
"src/content/blog/*.md": [
"node tools/update-blog-dates.js",
"git add src/_data/blog-dates.json"
],
"**/*.svg": "npx svgo -r --multipass"
},
"gitHooks": {
Expand Down
Loading