-
|
Hi all, Eleventy can get a post's date from the filename, for example, However the permalink for this post becomes Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
pdehaan
Jan 9, 2023
Replies: 1 comment 1 reply
-
|
You could create a directory data file which sets the module.exports = {
eleventyComputed: {
permalink(data) {
if (data.permalink) {
return data.permalink;
}
if (data.page.filePathStem.endsWith("/index")) {
return `${ data.page.filePathStem }.html`;
}
return `${ data.page.filePathStem }/`;
}
}
};tree -aI node_modules
.
├── .eleventy.js
├── package-lock.json
├── package.json
├── src/
│ └── pages/
│ ├── 2023-01-09-my-blog-post.md
│ ├── 2023-04-29-custom.md
│ ├── index.md
│ └── pages.11tydata.js
└── www/
├── hello/world/index.html
└── pages/
├── index.html
└── my-blog-post/index.html
7 directories, 10 files |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mendhak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could create a directory data file which sets the
permalinkvia aneleventyComputedfunction:tree -aI node_modules . ├── .eleventy.js ├── package-lock.json ├── package.json ├── src/ │ └── pages/ │ ├── 2023-01-09-my-blog-post.md │ ├── 2023-04-29-custom.md │ ├── index.md │ └── pages.11tydata.js └── www/ ├── hello/world/index.html └── pages/ ├── ind…