From 3d89492518afc5f904615cbad1ed688852132949 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 27 Oct 2023 20:43:57 -0400 Subject: [PATCH] Add regular link. --- .../templates/html/regular_link.dust | 2 +- src/context/regular_link.rs | 27 ++++++++++++++++--- src/intermediate/regular_link.rs | 18 +++++++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/default_environment/templates/html/regular_link.dust b/default_environment/templates/html/regular_link.dust index 8533fae..ba4b98a 100644 --- a/default_environment/templates/html/regular_link.dust +++ b/default_environment/templates/html/regular_link.dust @@ -1 +1 @@ -regular_link +{#.children}{>object/}{/.children} diff --git a/src/context/regular_link.rs b/src/context/regular_link.rs index 38bae6b..d245e0a 100644 --- a/src/context/regular_link.rs +++ b/src/context/regular_link.rs @@ -6,18 +6,39 @@ use crate::config::Config; use crate::error::CustomError; use crate::intermediate::IRegularLink; +use super::RenderObject; + #[derive(Debug, Serialize)] #[serde(tag = "type")] #[serde(rename = "regular_link")] -pub(crate) struct RenderRegularLink {} +pub(crate) struct RenderRegularLink { + path: String, + children: Vec, +} impl RenderRegularLink { pub(crate) fn new( config: &Config, output_directory: &Path, output_file: &Path, - comment: &IRegularLink, + regular_link: &IRegularLink, ) -> Result { - Ok(RenderRegularLink {}) + let children = { + let mut ret = Vec::new(); + for obj in regular_link.children.iter() { + ret.push(RenderObject::new( + config, + &output_directory, + &output_file, + obj, + )?); + } + ret + }; + + Ok(RenderRegularLink { + path: regular_link.path.clone(), + children, + }) } } diff --git a/src/intermediate/regular_link.rs b/src/intermediate/regular_link.rs index 2f06e4b..63080ea 100644 --- a/src/intermediate/regular_link.rs +++ b/src/intermediate/regular_link.rs @@ -1,15 +1,29 @@ use crate::error::CustomError; use super::registry::Registry; +use super::IObject; #[derive(Debug)] -pub(crate) struct IRegularLink {} +pub(crate) struct IRegularLink { + pub(crate) path: String, + pub(crate) children: Vec, +} impl IRegularLink { pub(crate) async fn new<'parse>( registry: &mut Registry<'parse>, original: &organic::types::RegularLink<'parse>, ) -> Result { - Ok(IRegularLink {}) + let children = { + let mut ret = Vec::new(); + for obj in original.children.iter() { + ret.push(IObject::new(registry, obj).await?); + } + ret + }; + Ok(IRegularLink { + path: original.path.as_ref().to_owned(), + children, + }) } }