spanezz / staticsite

Static site generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend staticsite

paternal opened this issue · comments

commented

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

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?

commented

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.

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.