Open mattip opened 3 years ago
It might be sufficient to add the 'public' path to the python code in sidebar.py
:
def set_site(self, site):
"""Set site."""
site.template_system.inject_directory('public') # add this line
super(RenderSidebar, self).set_site(site)
Then I can include the snippet in my templates
{% include 'sidebar-en.inc' %}
@mattip the problem with the sidebar is that its contents depend on essentially the whole site. So if the sidebar would already be included during the build in every page, every change to the site would require re-creating all pages. For small pages that's ok, for larger ones it's pretty excessive. That's why it generates a separate file that needs to be included in another step.
I personally use a substitution script / two-phase deployment to create a final version of the site with the sidebar included, to avoid the use of JavaScript to include it.
I personally use a substitution script / two-phase deployment to create a final version
With sed via a marker in the post template? I guess that could work too. My site (www.pypy.org after importing blog posts + comments from https://morepypy.blogspot.com in this MR) has ~500 posts and the strategy I outlined above requires about 3 seconds to recreate the pages, so I am not to worried about rebuilding once a week or so when we have new blog posts.
Rather than generate a sidebar-en.inc file as a task, perhaps the sidebar plugin could add a
set_site
method and add the sidebar as a blinker.signal callback, like static_comments does. This would make the snippet more useful since no server-side or javascript would be needed to include it. Did I understand correctly the sequence of processes?