Giter Site home page Giter Site logo

Comments (6)

vitch avatar vitch commented on August 10, 2024

I had a little look into this to see if I could figure out how to implement it myself and I have created a wintersmith-archive plugin:

https://github.com/vitch/wintersmith-archive

I've never written coffee script before so it's quite possibly a dumb implementation (not understanding coffee script made it tricky for me to get my head around the wintersmith sourcecode as well). But hopefully it is a starting point to discuss whether it is possible to move logic from templates into a ContentPlugin

To use add to your project and then reference in config.json. Now you can replace contents/archive.md from the default example install with contents/archive.json containing the following:

{
  "template": "archive.jade",
  "filename": "archive.html"
}

Then templates/archive.jade becomes:

extends layout

block content

  section.archive
    ul
      each dateData in sortedArticleDates
        li.year= dateData.year
        ul
          each month in dateData.months
            li
              strong= articlesByDate[dateData.year][month].monthName
              each article in articlesByDate[dateData.year][month].articles
                br
                a(href=article.url)= article.title

What do you think? Do you like the idea of making the templates dumber and simpler and having any required logic in a ContentPlugin?

from wintersmith.

joefiorini avatar joefiorini commented on August 10, 2024

@vitch I just went through this myself. I ended up hacking wintersmith-swig to allow me to pass a custom filters module, then created a file with swig filters to handle most of the logic that is currently done in the Jade template. I'd be happy to share some of the code here next time I'm at my computer; don't have access to it right now unfortunately. Would that help?

from wintersmith.

joefiorini avatar joefiorini commented on August 10, 2024

@vitch Also, your plugin looks good as long as I want the specific configuration (sorted by date, etc) you return. My solution allows you to define that in your app. However, it's not very "wintersmithy" whereas yours is, so maybe we can find a way to combine approaches?

from wintersmith.

vitch avatar vitch commented on August 10, 2024

@joefiorini I actually moved to DocPad in the meantime... This was one of the problems I ran into while evaluating wintersmith so I decided to have a looks at some other options and I'm currently preferring that...

Agree that my plugin is limited to the specific requirements at hand. It would be great to have it configurable in some manner (rather than a separate plugin for each way you want to slice the data)...

from wintersmith.

jnordberg avatar jnordberg commented on August 10, 2024

#56

from wintersmith.

jnordberg avatar jnordberg commented on August 10, 2024

Fixed in 2.0, now everything is PERFECT! ⛵

from wintersmith.

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.