weblorg icon indicating copy to clipboard operation
weblorg copied to clipboard

As blogger I want to be able to categorize my posts, so that my posts be organized.

Open guilhermecomum opened this issue 5 years ago • 1 comments

guilhermecomum avatar Aug 11 '20 00:08 guilhermecomum

There are a few things we need in order to get this working:

  1. the code for generating the pages for each category. the snippet below will generate a directory for each category name with an index.html file within it:

    (weblorg-route
     :name "categories"
     :input-pattern "posts/*.org"
     :input-aggregate #'weblorg-input-aggregate-by-category ;; also look at weblorg-input-aggregate-by-category-desc
     :template "category.html"
     :output "blog/{{ name }}/index.html"
     :url "/blog/{{ name }}")
    ;; the template will link to the `posts` route with `url_for`.
    (weblorg-route
     :name "posts"
     :input-pattern "posts/*.org"
     :template "post.html"
     :output "blog/{{ slug }}.html"
     :url "/blog/{{ slug }}.html")
    
  2. The category.html template present in the templates path (we don't have any themes shipping this file yet 😢)

    {% extends "layout.html" %}
    {% block body %}
      <div class="title"><h1>{{ category.name }}</h1></div>
      <div class="content">
        <ul>
          {% for post in category.posts %}
            <li>
              <span class="pubdate">{{ post.date }}</span>
              <a href="{{ url_for("posts", slug=post.slug) }}">{{ post.title }}</a>
            </li>
          {% endfor %}
        </ul>
      </div>
    {% endblock %}
    

clarete avatar Jan 03 '21 00:01 clarete