mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-09 10:06:40 -07:00
make resource tag list template configurable
This commit is contained in:
parent
db1a084885
commit
00c90a12d7
3 changed files with 9 additions and 4 deletions
|
@ -11,6 +11,7 @@ resources:
|
|||
output_path_long: blog
|
||||
resource_template: blog-post.tera
|
||||
resource_list_template: blog-list.tera
|
||||
tag_list_template: basic-link-list.tera
|
||||
rss_template: rss/blog-post.tera
|
||||
rss_title: zyl's blog
|
||||
rss_description: feed of recent blog posts on zyl's website.
|
||||
|
@ -24,6 +25,7 @@ resources:
|
|||
output_path_long: images
|
||||
resource_template: image.tera
|
||||
resource_list_template: images.tera
|
||||
tag_list_template: basic-link-list.tera
|
||||
rss_template: rss/image.tera
|
||||
rss_title: zyl's images
|
||||
rss_description: feed of newly uploaded images from zyl's website.
|
||||
|
|
|
@ -25,14 +25,14 @@ impl<'l> Link<'l> {
|
|||
/// Renders a basic list of links.
|
||||
pub fn render_basic_link_list(
|
||||
builder: &SiteBuilder,
|
||||
template: &str,
|
||||
links: Vec<Link>,
|
||||
title: &str,
|
||||
) -> eyre::Result<String> {
|
||||
let data = LinkTemplateData { links, title };
|
||||
let out = builder.tera.render(
|
||||
"basic-link-list.tera",
|
||||
&tera::Context::from_serialize(data)?,
|
||||
)?;
|
||||
let out = builder
|
||||
.tera
|
||||
.render(template, &tera::Context::from_serialize(data)?)?;
|
||||
let out = builder.build_page_raw(
|
||||
PageMetadata {
|
||||
title: Some(title.to_owned()),
|
||||
|
|
|
@ -146,6 +146,8 @@ pub struct ResourceBuilderConfig {
|
|||
pub resource_template: String,
|
||||
/// The template used to render a list of resources.
|
||||
pub resource_list_template: String,
|
||||
/// The template used to render the resource's tag pages.
|
||||
pub tag_list_template: String,
|
||||
/// Template used when rendering the RSS feed.
|
||||
pub rss_template: String,
|
||||
/// The RSS feed's title.
|
||||
|
@ -406,6 +408,7 @@ impl ResourceBuilder {
|
|||
.collect();
|
||||
let out = crate::link_list::render_basic_link_list(
|
||||
builder,
|
||||
&self.config.tag_list_template,
|
||||
links,
|
||||
&self.config.tag_list_title,
|
||||
)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue