required data prefix to extra data in templates now

resolves #12 and #13
This commit is contained in:
zyl 2024-11-13 08:35:11 -08:00
parent 281a181958
commit 83c5f6038f
Signed by: zyl
SSH key fingerprint: SHA256:uxxbSXbdroP/OnKBGnEDk5q7EKB2razvstC/KmzdXXs
4 changed files with 19 additions and 20 deletions

View file

@ -1,9 +1,9 @@
{% extends "base.tera" %}
{% block content %}
<h1>{{ title }}</h1>
<h1>{{ data.title }}</h1>
<div class="link-list">
<ul>
{% for link in links %}
{% for link in data.links %}
<li><a href="{{link.link}}">{{link.title}}</a></li>
{% endfor %}
</ul>

View file

@ -1,23 +1,23 @@
{% extends "base.tera" %}
{% block content %}
<div class="blog-post">
<h1 class="title">{{title}}</h1>
<span class="timestamp">published {{timestamp}}</span>
{% if draft %}
<h1 class="title">{{data.title}}</h1>
<span class="timestamp">published {{data.timestamp}}</span>
{% if data.draft %}
<h2>DRAFT</h2>
{% endif %}
<div class="header-image-wrapper">
<p class="short-desc">{{desc}}</p>
<img class="header-image" src="{{cdn_file}}" alt="{{header_image_alt}}"
<p class="short-desc">{{data.desc}}</p>
<img class="header-image" src="{{data.cdn_file}}" alt="{{data.header_image_alt}}"
style="object-fit: cover; object-position: 50% 50%">
</div>
<div class="content">
{{ content | safe }}
{{ data.content | safe }}
</div>
<hr />
<h3 class="tags-title">tags</h3>
<div class="post-tags">
{% for tag in tags %}
{% for tag in data.tags %}
<a class="tag" href="/blog/tag/{{tag}}">{{tag}}</a>{% if not loop.last %},{% endif %}
{% endfor %}
</div>

View file

@ -1,22 +1,22 @@
{% extends "base.tera" %}
{% block content %}
{% if tag %}
<h1>blog posts tagged {{tag}}</h1>
{% if data.tag %}
<h1>blog posts tagged {{data.tag}}</h1>
<p><a href="/blog/">View all blog posts</a></p>
{% else %}
<h1>blog Posts</h1>
<p><a href="tags">view blog tags</a></p>
<p><a href="rss.xml">rss feed</a></p>
{% endif %}
<h1>Page {{page}}/{{page_max}}</h1>
{% if previous %}
<a href="./{{previous}}">previous page</a>
<h1>Page {{data.page}}/{{data.page_max}}</h1>
{% if data.previous %}
<a href="./{{data.previous}}">previous page</a>
{% endif %}
{% if next %}
<a href="./{{next}}">next page</a>
{% if data.next %}
<a href="./{{data.next}}">next page</a>
{% endif %}
<div class="blog-post-list">
{% for resource in resources %}
{% for resource in data.resources %}
<div class="post">
<p class="title"><a href="/blog/{{resource.id}}">{{resource.title}}</a></p>
<p class="timestamp">{{resource.timestamp}}</p>

View file

@ -29,8 +29,7 @@ struct TemplateData<'a, T> {
/// the page's custom styles.
pub styles: &'a [String],
/// Custom template data.
#[serde(flatten)]
pub extra_data: T,
pub data: T,
}
/// Struct used to build the site.
@ -303,7 +302,7 @@ impl SiteBuilder {
head,
scripts: &page_metadata.scripts,
styles: &page_metadata.styles,
extra_data,
data: extra_data,
})?,
)?;