From 96e180703b56675da5bc8a17e12f3b3f4b050d59 Mon Sep 17 00:00:00 2001 From: yuki Date: Sat, 18 Oct 2025 02:56:07 -0300 Subject: [PATCH] slugify override and default --- es/blog/blog.11tydata.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/es/blog/blog.11tydata.js b/es/blog/blog.11tydata.js index a73f13b..def8c5c 100644 --- a/es/blog/blog.11tydata.js +++ b/es/blog/blog.11tydata.js @@ -1,8 +1,7 @@ module.exports = { eleventyComputed: { - // TODO: handle titles as slugs instead of filenames - permalink: (data) => { - // get the file path stem, e.g., "/es/blog/2025/2025-10-18-my-post" + permalink: function (data) { + // get the file path stem let stem = data.page.filePathStem; // extract the year from the path @@ -12,14 +11,14 @@ module.exports = { // check for slug_override first if (data.slug_override) { - return `/es/blog/${year}/${data.slug_override}/index.html`; // ie /es/blog/2025/post-localizado/index.html + return `/es/blog/${year}/${this.slugify(data.slug_override)}/index.html`; } // handle blog posts with date prefix: /es/blog/[year]/[year-month-day]-slug const blogPostMatch = stem.match(/^\/es\/blog\/(\d{4})\/\d{4}-\d{2}-\d{2}-(.+)$/); if (blogPostMatch) { const [, , slug] = blogPostMatch; - return `/es/blog/${year}/${this.slugify(slug)}/index.html`; // ie /es/blog/2025/my-post/index.html + return `/es/blog/${year}/${this.slugify(slug)}/index.html`; } }