mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-09 18:16: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
|
output_path_long: blog
|
||||||
resource_template: blog-post.tera
|
resource_template: blog-post.tera
|
||||||
resource_list_template: blog-list.tera
|
resource_list_template: blog-list.tera
|
||||||
|
tag_list_template: basic-link-list.tera
|
||||||
rss_template: rss/blog-post.tera
|
rss_template: rss/blog-post.tera
|
||||||
rss_title: zyl's blog
|
rss_title: zyl's blog
|
||||||
rss_description: feed of recent blog posts on zyl's website.
|
rss_description: feed of recent blog posts on zyl's website.
|
||||||
|
@ -24,6 +25,7 @@ resources:
|
||||||
output_path_long: images
|
output_path_long: images
|
||||||
resource_template: image.tera
|
resource_template: image.tera
|
||||||
resource_list_template: images.tera
|
resource_list_template: images.tera
|
||||||
|
tag_list_template: basic-link-list.tera
|
||||||
rss_template: rss/image.tera
|
rss_template: rss/image.tera
|
||||||
rss_title: zyl's images
|
rss_title: zyl's images
|
||||||
rss_description: feed of newly uploaded images from zyl's website.
|
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.
|
/// Renders a basic list of links.
|
||||||
pub fn render_basic_link_list(
|
pub fn render_basic_link_list(
|
||||||
builder: &SiteBuilder,
|
builder: &SiteBuilder,
|
||||||
|
template: &str,
|
||||||
links: Vec<Link>,
|
links: Vec<Link>,
|
||||||
title: &str,
|
title: &str,
|
||||||
) -> eyre::Result<String> {
|
) -> eyre::Result<String> {
|
||||||
let data = LinkTemplateData { links, title };
|
let data = LinkTemplateData { links, title };
|
||||||
let out = builder.tera.render(
|
let out = builder
|
||||||
"basic-link-list.tera",
|
.tera
|
||||||
&tera::Context::from_serialize(data)?,
|
.render(template, &tera::Context::from_serialize(data)?)?;
|
||||||
)?;
|
|
||||||
let out = builder.build_page_raw(
|
let out = builder.build_page_raw(
|
||||||
PageMetadata {
|
PageMetadata {
|
||||||
title: Some(title.to_owned()),
|
title: Some(title.to_owned()),
|
||||||
|
|
|
@ -146,6 +146,8 @@ pub struct ResourceBuilderConfig {
|
||||||
pub resource_template: String,
|
pub resource_template: String,
|
||||||
/// The template used to render a list of resources.
|
/// The template used to render a list of resources.
|
||||||
pub resource_list_template: String,
|
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.
|
/// Template used when rendering the RSS feed.
|
||||||
pub rss_template: String,
|
pub rss_template: String,
|
||||||
/// The RSS feed's title.
|
/// The RSS feed's title.
|
||||||
|
@ -406,6 +408,7 @@ impl ResourceBuilder {
|
||||||
.collect();
|
.collect();
|
||||||
let out = crate::link_list::render_basic_link_list(
|
let out = crate::link_list::render_basic_link_list(
|
||||||
builder,
|
builder,
|
||||||
|
&self.config.tag_list_template,
|
||||||
links,
|
links,
|
||||||
&self.config.tag_list_title,
|
&self.config.tag_list_title,
|
||||||
)?;
|
)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue