Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 0.5.0-dev

* Remove unused function clif that was the original entrypoint #81 0.5.0.dev8
* Allow template variables to be used in head config #88 0.5.0.dev11
* Expose `markata.__version__` to templates as `__version__` #89 0.5.0.dev12
* Fix #33 sluggify paths #69 **BREAKING CHANGE** 0.5.0.dev6
* Configurable template #70 0.5.dev5, #85 0.5.0.dev11
* Fix #40 Images overlfow outside of body #66 0.5.0.dev3
Expand Down
4 changes: 4 additions & 0 deletions markata.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ card_template="<li class='post'><a href='/{{ slug }}/'>{{ title }}</a></li>"
[markata.jinja_md]
ignore=[
'jinja_md.md',
'post_template.md',
'publish_html.md',
]

[[markata.head.meta]]
name = "og:author_email"
content = "waylon@waylonwalker.com"

8 changes: 5 additions & 3 deletions markata/plugins/post_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from jinja2 import Template, Undefined
from more_itertools import flatten

from markata import __version__
from markata.hookspec import hook_impl

env = jinja2.Environment()
Expand Down Expand Up @@ -109,9 +110,9 @@ def render(markata: "Markata") -> None:
with open(template_file) as f:
template = Template(f.read(), undefined=SilentUndefined)

if "{{" in str(markata.config.get("head")):
if "{{" in str(markata.config.get("head", {})):
head_template = Template(
str(markata.config.get("head")), undefined=SilentUndefined
str(markata.config.get("head", {})), undefined=SilentUndefined
)
else:
head_template = None
Expand All @@ -120,9 +121,10 @@ def render(markata: "Markata") -> None:
for article in markata.iter_articles("apply template"):

if head_template:
head = eval(head_template.render(**article, config=markata.config))
head = eval(head_template.render(__version__=__version__, config=markata.config, **article))

article.html = template.render(
__version__=__version__,
body=article.html,
toc=markata.md.toc, # type: ignore
config={
Expand Down