diff options
Diffstat (limited to 'src/directive/inline.rs')
-rw-r--r-- | src/directive/inline.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/directive/inline.rs b/src/directive/inline.rs index e6577b2..0dafa69 100644 --- a/src/directive/inline.rs +++ b/src/directive/inline.rs @@ -1,3 +1,4 @@ +use crate::directive::DirectiveImplementation; use crate::error::SiteError; use crate::page::PageMeta; use crate::pagespec::PageSpec; @@ -11,9 +12,9 @@ pub struct Inline { pages: String, } -impl Inline { - pub const REQUIRED: &'static [&'static str] = &["pages"]; - pub const ALLOWED: &'static [&'static str] = &[ +impl DirectiveImplementation for Inline { + const REQUIRED: &'static [&'static str] = &["pages"]; + const ALLOWED: &'static [&'static str] = &[ "actions", "archive", "description", @@ -29,13 +30,15 @@ impl Inline { "template", "trail", ]; - pub const ALLOW_ANY_UNNAMED: bool = true; + const ALLOW_ANY_UNNAMED: bool = true; - pub fn new(pages: String) -> Self { - Self { pages } + fn from_parsed(p: &ParsedDirective) -> Self { + let args = p.args(); + let pages = args.get("pages").unwrap(); + Inline::new(pages.to_string()) } - pub fn process(&self, site: &Site, meta: &mut PageMeta) -> Result<String, SiteError> { + fn process(&self, site: &Site, meta: &mut PageMeta) -> Result<String, SiteError> { let pagespec = PageSpec::new(meta.path(), &self.pages)?; let matches: Vec<String> = site .markdown_pages() @@ -45,17 +48,15 @@ impl Inline { .collect(); Ok(matches.join("")) } +} + +impl Inline { + pub fn new(pages: String) -> Self { + Self { pages } + } fn link(container: &Path, meta: &PageMeta) -> String { let link = make_relative_link(container, meta.path()); format!("[{}]({})", meta.title(), link.display()) } } - -impl From<&ParsedDirective> for Inline { - fn from(p: &ParsedDirective) -> Self { - let args = p.args(); - let pages = args.get("pages").unwrap(); - Inline::new(pages.to_string()) - } -} |