19 lines
830 B
JavaScript
19 lines
830 B
JavaScript
|
|
// content/editions/editions.11tydata.js
|
||
|
|
module.exports = {
|
||
|
|
eleventyComputed: {
|
||
|
|
// Dynamically build the permalink based on the folder date and file slug
|
||
|
|
permalink: (data) => {
|
||
|
|
// If it's the index.md of the edition, route to /archive/YYYY-MM-DD/
|
||
|
|
if (data.page.fileSlug === 'index' || data.page.fileSlug === '') {
|
||
|
|
// Extract date from the parent folder name
|
||
|
|
const folderName = data.page.filePathStem.split('/').slice(-2, -1)[0];
|
||
|
|
return `/archive/${folderName}/`;
|
||
|
|
}
|
||
|
|
|
||
|
|
// If it's an article, route to /archive/YYYY-MM-DD/article-slug/
|
||
|
|
const folderName = data.page.filePathStem.split('/').slice(-3, -2)[0];
|
||
|
|
return `/archive/${folderName}/${data.page.fileSlug}/`;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|