Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uncenter/11ty-demo-modified-created-dates
https://github.com/uncenter/11ty-demo-modified-created-dates
11ty demo eleventy
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/uncenter/11ty-demo-modified-created-dates
- Owner: uncenter
- Created: 2023-11-30T01:40:29.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-16T18:40:11.000Z (11 months ago)
- Last Synced: 2024-10-13T14:21:10.169Z (about 1 month ago)
- Topics: 11ty, demo, eleventy
- Language: JavaScript
- Homepage: https://11ty-demo-modified-created-dates.pages.dev/
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 11ty-demo-modified-created-dates
A demo for creating custom date properties in Eleventy front matter.
## Usage
```
git clone https://github.com/uncenter/11ty-demo-modified-created-dates.git
npm install
npm run start
```### Deployment
Note that this requires Git history, which not all providers fetch all of. If this doesn't work in production, try setting the build command to `git fetch --unshallow && pnpm run build` instead of just `pnpm run build`.
See https://www.answeroverflow.com/m/1141603660007211149, https://www.brycewray.com/posts/2023/02/get-good-git-info-even-hosts-gui/.
## Explanation
This demo uses the internal utitility functions Eleventy uses for special [Content Dates](https://www.11ty.dev/docs/dates/) to set custom date properties, `created` and `modified`. The functions were copied into `src/posts/posts.11tydata.js` (see [Computed Data — Eleventy](https://www.11ty.dev/docs/data-computed/)), which applies the two properties to every post/template inside the `src/posts/` directory.