using variables inside content.lr
zongyaojin opened this issue · comments
Is it possible to render the following contents.lr file such that the rendered post displays the values of the variables, instead of the raw "body" section?
title: Post 1
---
pub_date: 2023-09-14
---
author: ABC
---
body:
This is example blog post #1.
<h2>{{ this.author }}</h2>
<h3>{{ bag('a-json-file')['a-key'] }}</h3>
This is not currently possible in Lektor by default.
I did however, write a plugin for this a while back that renders a lot of string-like fields, including markdown, with the typical page context included in the render. https://github.com/terminal-labs/lektor-jinja-content. Intermittently I've been going back to it to try to make it a bit more robust and flexible, but it works pretty well. Try it out :)
For now I'll close this issue, since it's a fairly straight forward Q and A. We can reopen it if it becomes more constructive on Lektor proper. If you have questions about that plugin, please head to that repo.