-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How to explicitly set all posts in a route or site? #48
Comments
oh hi @markokocic you might be interested in trying out the experimental (and undocumented 😢) Here's an example: https://github.com/emacs-love/weblorg/blob/main/themes/autodoc/templates/doc.html#L18-L26 It can take arbitrary route names and it will return all the posts of that route! Let me know if that works for you! and sorry for taking so long to answer things! I'm catching up 😄 |
Works like charm. Thanks 😊 |
Nice! I'll keep this open as a documentation issue then! Thank you for trying it out, @markokocic 🙇🏾 |
Hi @clarete Actually, after some testing I noticed that I have the following snippet in my sidebar template which is included from the base template: <section>
<h3>Recent Posts</h3>
<ul>
{% for recent in weblorg_route_posts("archive")|take(4) %}
<li><a href="{{ url_for("posts", slug=recent.slug) }}">{{ recent.title }}</a></li>
{% endfor %}
</ul>
</section> I also have the following routes defined in publish.el: (weblorg-route
;; route for rendering each post
:site blog
:name "posts"
:input-pattern "posts/*.org"
:template "post.html"
:output "output/posts/{{ slug }}.html"
:url "/posts/{{ slug }}.html")
(weblorg-route
;; route for rendering archive page
:site blog
:name "archive"
:input-pattern "posts/*.org"
:input-aggregate #'weblorg-input-aggregate-all-desc
:template "archive.html"
:output "output/archive.html"
:url "/archive.html") If I use Could be something to do with how the posts are aggregated, since the structure returned by |
oh, thank you for the feedback on this @markokocic. I think you might be right about the relationship with how aggregation works. That's still a bit too entangled to just the Org-Mode parsing. I want to make it more generic so we can address this sort of use case you presented. Thank you for the good repro of the issue, I'll take a stab at fixing it! |
In the end I was able to list recent posts by using the following template. <section>
<h3>Recent Posts</h3>
<ul>
{% for recent in weblorg_route_posts("archive") | attr("posts") | take(4) %}
<li><a href="{{ url_for("posts", slug=recent.slug) }}">{{ recent.title }}</a></li>
{% endfor %}
</ul>
</section> It works, but the solution looks wrong. |
I want to have a list of all posts/pages matching some filter and have it available inside a route or site.
Lets say I have a rout to render all posts:
I want to add two more variable to the each page, so that I can list links to pages in sidebar, and display 4 recent posts title in footer. For that I would like to have something like:
or directly in weblorg-site, in order to avoid duplication for each route.
Is something like this already possible in weblorg?
The text was updated successfully, but these errors were encountered: