spanezz / staticsite

Static site generator
GNU General Public License v3.0
46 stars 7 forks source link

Extend staticsite #11

Closed paternal closed 4 years ago

paternal commented 6 years ago

Hello, is there a way to extend staticsite with custom commands (corresponding to directives)? I know that I could write a markdown extension, but I am not sure that the code of this extension would be passed the staticsite "context" (e.g. setting and page variables). -- Louis

spanezz commented 4 years ago

Unfortunately it is not possible to pass extra context to the markdown engine. I find this very frustrating, and I had to work around it with a hack to resolve links (see staticsite.features.markdown.LinkResolver.set_page and its use).

Now that it is possible to add custom features to a site, it's possible to run arbitrary python code and interact with existing features like the markdown one (the staticsite.features.markdown.MarkdownPages instance is accessible from a Feature as self.site.features["md"]).

If you are still in need of this, we can see how to register hooks to MarkdownPages to be called when starting to render a page, which you could then use to make the Page object available to your markdown extension. Would that help?

paternal commented 4 years ago

I asked this question when I was looking for a new static site generator (moving from Ikiwiki). I eventually chose Lektor, and although I do miss Ikiwiki, I am not planning to switch to yet another static site generator in a near future. Thanks for your reply, nonetheless.

spanezz commented 4 years ago

Thanks, I'll close this issue then.

Thanks for point to lektor, I didn't know if yet, and now I'm curious to check it out.