mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-10 02:26:42 -07:00
make rss feeds optional for resources
This commit is contained in:
parent
95a0765b1e
commit
ddeb079d52
7 changed files with 101 additions and 65 deletions
22
src/main.rs
22
src/main.rs
|
@ -6,7 +6,7 @@ use time::{format_description::well_known::Rfc3339, OffsetDateTime};
|
|||
use url::Url;
|
||||
use webdog::{
|
||||
frontmatter::FrontMatter,
|
||||
resource::{ResourceBuilderConfig, ResourceMetadata},
|
||||
resource::{ResourceBuilderConfig, ResourceMetadata, ResourceRSSBuilderConfig},
|
||||
PageMetadata, Site, SiteConfig,
|
||||
};
|
||||
|
||||
|
@ -93,6 +93,9 @@ enum ResourceCommands {
|
|||
name: String,
|
||||
/// The name of the resource type, but plural.
|
||||
plural: String,
|
||||
/// Whether to skip enabling RSS for this resource or not.
|
||||
#[arg(long, default_value = "false")]
|
||||
no_rss: bool,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -163,7 +166,12 @@ fn main() -> eyre::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
Commands::Resource { command } => match command {
|
||||
ResourceCommands::Create { id, name, plural } => {
|
||||
ResourceCommands::Create {
|
||||
id,
|
||||
name,
|
||||
plural,
|
||||
no_rss,
|
||||
} => {
|
||||
let config_path = cli.site.join(SiteConfig::FILENAME);
|
||||
let mut config = SiteConfig::read(&cli.site)?;
|
||||
if config.resources.contains_key(&id) {
|
||||
|
@ -196,6 +204,12 @@ fn main() -> eyre::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
let rss = (!no_rss).then(|| ResourceRSSBuilderConfig {
|
||||
template: format!("{id}/rss.tera"),
|
||||
title: id.clone(),
|
||||
description: Default::default(),
|
||||
});
|
||||
|
||||
let resource_config = ResourceBuilderConfig {
|
||||
source_path: id.clone(),
|
||||
output_path_resources: id.clone(),
|
||||
|
@ -203,9 +217,7 @@ fn main() -> eyre::Result<()> {
|
|||
resource_template: format!("{id}/resource.tera"),
|
||||
resource_list_template: format!("{id}/list.tera"),
|
||||
tag_list_template: "basic-link-list.tera".to_string(),
|
||||
rss_template: format!("{id}/rss.tera"),
|
||||
rss_title: id.clone(),
|
||||
rss_description: Default::default(),
|
||||
rss,
|
||||
list_title: name.clone(),
|
||||
tag_list_title: format!("{name} tags"),
|
||||
resource_name_plural: plural,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue