Giter VIP home page Giter VIP logo

Comments (5)

madrilene avatar madrilene commented on June 4, 2024 1

(did you export the filter?)
https://github.com/madrilene/lenesaile.com/blob/main/config/filters/index.js#L218

from eleventy-excellent.

phillocoder avatar phillocoder commented on June 4, 2024 1

(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

from eleventy-excellent.

madrilene avatar madrilene commented on June 4, 2024

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://github.com/madrilene/lenesaile.com/blob/a8201804290ec1d7955dbadd79cfd4ab5aa1ac61/src/_includes/partials/date.njk#L4-L7

https://www.lenesaile.com/en/blog/internationalization-with-eleventy-20-and-netlify/

from eleventy-excellent.

phillocoder avatar phillocoder commented on June 4, 2024

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://github.com/madrilene/lenesaile.com/blob/a8201804290ec1d7955dbadd79cfd4ab5aa1ac61/src/_includes/partials/date.njk#L4-L7

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)

from eleventy-excellent.

madrilene avatar madrilene commented on June 4, 2024

I'd need to see your code!

from eleventy-excellent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.