Closed phillocoder closed 1 year ago
Hey, yeah, that's not a problem. You can see on my website (which is structured very similar) how to solve this. dayjs comes with locales, you can call them in the filter configs.
https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L3 https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L103
You then import the new filter into your config file
https://github.com/madrilene/lenesaile.com/blob/main/.eleventy.js#L28 https://github.com/madrilene/lenesaile.com/blob/main/.eleventy.js#L114
You can then apply the filter directly here (if you only have one language): https://github.com/madrilene/eleventy-excellent/blob/main/src/_includes/partials/date.njk
<time datetime="{{ definedDate | toIsoString }}">
{{
definedDate | formatDateDE('D. MMMM YYYY')
}}
</time>
My site is multilingual, but for this to work you have to set some more things.
https://www.lenesaile.com/en/blog/internationalization-with-eleventy-20-and-netlify/
Hey, yeah, that's not a problem. You can see on my website (which is structured very similar) how to solve this. dayjs comes with locales, you can call them in the filter configs.
https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L3 https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L103
You then import the new filter into your config file
https://github.com/madrilene/lenesaile.com/blob/main/.eleventy.js#L28 https://github.com/madrilene/lenesaile.com/blob/main/.eleventy.js#L114
You can then apply the filter directly here (if you only have one language): https://github.com/madrilene/eleventy-excellent/blob/main/src/_includes/partials/date.njk
<time datetime="{{ definedDate | toIsoString }}"> {{ definedDate | formatDateDE('D. MMMM YYYY') }} </time>
My site is multilingual, but for this to work you have to set some more things.
https://www.lenesaile.com/en/blog/internationalization-with-eleventy-20-and-netlify/
Hello, thanks for your help. The first two steps are working, but when I change the date.njk the build fails with a template render error: (./src/_includes/partial/date.njk)
I'd need to see your code!
(did you export the filter?) https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L218
(did you export the filter?) https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L218
That's it, I think. Thank you very much
Is there any way to change the language of the blog post dates from english to something else? I tried things for some time now but I can't seem to figure out any solution. Thanks