home.social

#nunjucks — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #nunjucks, aggregated by home.social.

  1. Useful @11ty filters for #Nunjucks / #Liquid via github.com/anydigital/eleventy plugin:

    - attr_concat
    - attr_includes
    - attr_set
    - fetch
    - if
    - merge
    - remove_tag
    - strip_tag
    - section
    - unindent

    Docs: blades.ninja/build-awesome-11t

  2. Yet another #TIL with @11ty

    It looks like data coming from global data files is not available inside #Nunjucks macros… 😭

    (maybe I already knew this, but I forgot, and lost a few hours today…)

  3. Another weird issue with #Eleventy #Nunjucks templates…

    I have these two lines:

    {% set photos = page.data.photos %}
    {{ page.data.photos | length }} / {{ photos | length }}

    The result is:

    0 / 24

    What the… 🤨

    EDIT: the issue was me all along… 😞

    mamot.fr/@nhoizey/115028557519

  4. I refactored my personal website on @11ty from #Nunjucks to #Vento, and I have some tips for you if you want to do the same. It's like a guide but like… less structured and more pun-riddled. Check it out: chriskirknielsen.com/blog/from

  5. Looking to migrate an existing website to 11ty. It's predominantly blog content, and the blog posts themselves will be in Markdown. But I'm at a bit of a loss around which template language to use.

    I'm very familiar with TSX, so maybe I should stick with that? Is there a reason to use something like Nunjucks instead?

    #11ty #eleventy #markdown #tsx #nunjucks #blog #webdev

  6. Writing this down for future me but I gotta figure out if there's a way for nunjucks conditionals to detect if the child in a loop is the "first child" or not.

    Because I'd love to make it so when it's the first child it adds an id.

    For now though I'm taking a little break from today's coding & getting a sip of water instead. :KermitTea:

    #WebDev #11ty #Coding #Eleventy #NunJucks

  7. @seav For sure #Liquid or #Nunjucks. I personally always use Liquido because it’s great, but Nunjucks gas a few things the former doesn’t have, and vice versa.

    @eleventy

  8. I’m planning to create my first @eleventy site soon and I’m already wondering which template language to use. Given that #Eleventy supports several formats, there’s a minor #ParadoxOfChoice at play here. I’ll probably just go with #Nunjucks for its flexibility.

    #11ty #webdev #SSGs

  9. I’m planning to create my first @eleventy site soon and I’m already wondering which template language to use. Given that #Eleventy supports several formats, there’s a minor #ParadoxOfChoice at play here. I’ll probably just go with #Nunjucks for its flexibility.

    #11ty #webdev #SSGs

  10. I’m planning to create my first @eleventy site soon and I’m already wondering which template language to use. Given that #Eleventy supports several formats, there’s a minor #ParadoxOfChoice at play here. I’ll probably just go with #Nunjucks for its flexibility.

    #11ty #webdev #SSGs

  11. I’m planning to create my first @eleventy site soon and I’m already wondering which template language to use. Given that #Eleventy supports several formats, there’s a minor #ParadoxOfChoice at play here. I’ll probably just go with #Nunjucks for its flexibility.

    #11ty #webdev #SSGs

  12. I’m planning to create my first @eleventy site soon and I’m already wondering which template language to use. Given that #Eleventy supports several formats, there’s a minor #ParadoxOfChoice at play here. I’ll probably just go with #Nunjucks for its flexibility.

    #11ty #webdev #SSGs

  13. For my website, I have replaced the estimated reading time of my blog posts with word count, by using the eleventy-plugin-wordcount-extended plugin.

    Through this plugin, I also learned that Nunjucks has a built-in `wordcount` filter, but it does not correctly calculate the word count of non-ASCII strings, including Chinese characters and emojis.

    #Eleventy #Nunjucks

  14. I enjoyed the article by @BryceWrayTX about moving on from #Nunjucks when writing #11ty templates.

    I've wanted to check out #WebComponents for a while and this seems like a great way to start.

    brycewray.com/posts/2023/03/ti

  15. Gonna ask here just in case. Is there a way to fetch all the pagination URLs of a specific page? I'm trying to make a nunjucks for loop that generates a list of links of all the available paginations of a specific page. Output example:

    <ul>
    <li><a href="list1/pageb/test-name/">page 1</a></li>
    <li><a href="list1/pageb/test-name/1/">page 2</a></li>
    <li><a href="list1/pageb/test-name/2/">page 3</a></li>
    </ul>

    #NunJucks #11ty #Coding #WebDev

  16. Man, it feels so good to learn and understand more and more about #Eleventy, and as a result a bunch of other stuffs that are tightly knit with it like #Node, #Javascript, #Nunjucks and even improve my existing skills like #HTML and #CSS (in which, also from this learning endeavour, I've discovered and migrated to using #Sass!).

    Special thanks to
    @[email protected] for the encouragement/push I needed to start learning #11ty in the first place ​:blobfoxcat:​

  17. Man #Nunjucks is a pain the more I'm using it lol, and it's all due to their whitespace control. It's fine if all you want is to output to HTML and you're not gonna check the resulting source of your pages/views, but when you're using it to output any other type of files where indentations matter more like Markdown or just about anything else that aren't necessarily for the web, you will be in a sea of pain figuring out how the hell are you gonna control whitespaces just about everywhere like content blocks, if blocks, for loop blocks, etc.

  18. Hmm... I know I can programmatically create #HTML/#Markdown files in #Eleventy pretty easily, but what is a good/simple way to also create a #PDF file out of them that could be downloaded?

    I found this guide, but it's not working out from my test (granted, I know almost nothing of
    #Javascript). It's also using an #Adobe API which isn't unconditionally free, though I'm fine with that unless there's a better way/alternative. Also said API doesn't seem to actually support creating PDF out of Markdown though.

    The idea is I'd use
    #Nunjucks to create HTML and Markdown files, then for files I intend to turn to PDFs (i.e. based on their permalink), I'd want them to be converted to PDFs and output to a specific directory.

    🔗 https://www.raymondcamden.com/2021/10/13/adding-pdf-output-supports-to-eleventy

    🔗 https://developer.adobe.com/document-services/docs/overview/pdf-services-api/howtos/create-pdf

  19. {{ sitedata.title | default("Home") }}

    It's interesting how in
    #Nunjucks/#11ty the default value gets used if the title key does not exist to begin with, but if it does exist but has no value in the sitedata data file i.e. "title": "", the default value does not get used.

    That's a lil different than other templating languages/engines I'm used to, like with
    #Helm for example. Am I doing something wrong, or am I expected to always add in an if block to check for its value and supplying a default value if it does not exist or is empty?

    The
    workaround I found that seems a lil silly is to do this instead:
    {{ sitedata.title or sitedata.non_existent_key  | default("Home") }}

    This way for whatever reason, even when
    title exists but has an empty value, it'd fall back to non_existent_key which does not exist, hence, uses the default value supplied haha.

  20. Early days learning #11ty, it really feels like a build your own version of #Django where they both essentially achieve the same thing, but with slight differences between them. Too early to tell, but I'm already starting to wonder how to do certain things I'm used to doing on Django but on 11ty like sourcing posts from a database for example.

    I've a habit of thinking too much ahead tho which makes things a lil daunting but I'm certain it really isn't as long as I pipe down the pace a notch. I'm quite determined now to make a personal website with 11ty instead of Django bcos I've a feeling if I get the hang of it, 11ty should be more lightweight and suited for that sort of thing.

    Templating language of choice though - I see that it supports several, and I'm sure there's no
    right answers, but is #Nunjucks a good choice? Seems pretty similar to Django's templating language, and I imagine something like #Jinja too?

    🔗 https://www.11ty.dev/docs/languages

  21. CW: WebDev eyestrain:

    Does anyone know why nunjucks conditionals don't work when there's a dash? Code example:

    {% for post in collections.story-1 %}
    <li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
    {% endfor %}

    Because when I wrote this instead of looking for markdown files with the "story-1" tag like expected nothing loads. (There's no terminal errors either.)

    1st screenshot is how I want it to look, 2nd screenshot is what shows up.

    #WebDev #Coding #11ty #Nunjucks

  22. Spoilered screenshots because they're eyestrain.

    Thank you to @eladnarra for helping me get this working! I'm so happy that it came to fruition! 😁

    Basically I added a nunjucks conditional that checks if I added any content warnings to the frontmatter. If I did it makes a details tag with a list of all the triggers within it. That way readers can have the option to check if they want/need, best of both worlds! :SickosYes:

    #WebDev #Coding #11ty #Nunjucks

  23. I'm about to start using #Git for the first time, to make the development of my new #11ty site a bit easier. Learning both #Nunjucks and modern #CSS leads to a lot of manual rollbacks I hope will become easier.

    I've read a lot about Git, but one question lingers still: I’m building my site based on #Eleventy Base Blog, in a repo I cloned using #Github Desktop.

    How do I disconnect (or whatever the technical term is) from the original Github repo and turns it into a private of my own?

  24. TIL: you can do wild things with #OrgFormation tasks and #Nunjucks templates to programmatically generate #CloudFormation code!

    I don't know how I feel about this! 🤗
    I mean, look at this beautifully triple-nested loop! 👀

    ⚠️ OK, Don't try this at home!

    #AWS #Shenanigans

  25. The website was built in
    @eleventy
    , a fantastic static site generator I can highly recommend to everybody who likes to build his sites hands-on without big CMS overhead.

    Big thanks to
    @zachleat
    for creating this great tool and to the discord community and my beta testers for all the help!

    #website #eleventy #nodejs #staticsite #nerdheaven #nunjucks #ownyoursite