[][src]Struct bloguen::ops::PostMetadata

pub struct PostMetadata {
    pub language: Option<LanguageTag>,
    pub author: Option<String>,
    pub tags: Vec<TagName>,
    pub styles: Vec<StyleElement>,
    pub scripts: Vec<ScriptElement>,
    pub data: BTreeMap<String, String>,
}

Generic post metadata.

Fields

language: Option<LanguageTag>

Post language override.

If not present, default post language is used.

author: Option<String>

Post author override.

If not present, default post author is used.

tags: Vec<TagName>

A set of tags.

If not present, defaults to empty.

styles: Vec<StyleElement>

A set of style descriptors.

If not present, defaults to empty.

scripts: Vec<ScriptElement>

A set of style descriptors.

If not present, defaults to empty.

data: BTreeMap<String, String>

Additional static data to substitute in header and footer.

If not present, defaults to empty.

Methods

impl PostMetadata[src]

pub fn read_or_default(
    post_root: &(String, PathBuf)
) -> Result<PostMetadata, Error>
[src]

Read the post metadata from the specified root directory.

If the metadata file doesn't exist, Ok(Default::default()) is returned.

Examples

Given $POST_ROOT/metadata.toml containing:

language = "pl"
tags = ["vodka", "depression"]

[[scripts]]
class = "link"
data = "/content/assets/syllable.js"

[[scripts]]
class = "file"
data = "MathJax-config.js"

[data]
desc = "Każdy koniec to nowy początek [PL]"

The following holds:

let post_root: PathBuf = /* obtained elsewhere */;
let metadata =
    PostMetadata::read_or_default(&("$POST_ROOT/".to_string(), post_root.clone())).unwrap();
assert_eq!(metadata,
           PostMetadata {
               language: Some("pl".parse().unwrap()),
               author: None,
               tags: vec!["vodka".parse().unwrap(), "depression".parse().unwrap()],
               styles: vec![],
               scripts: vec![ScriptElement::from_link("/content/assets/syllable.js"),
                             ScriptElement::from_path("MathJax-config.js")],
               data: vec![("desc".to_string(),
                           "Każdy koniec to nowy początek [PL]".to_string())]
                         .into_iter().collect(),
           });

Trait Implementations

impl Eq for PostMetadata[src]

impl Default for PostMetadata[src]

impl Clone for PostMetadata[src]

impl PartialOrd<PostMetadata> for PostMetadata[src]

impl PartialEq<PostMetadata> for PostMetadata[src]

impl Ord for PostMetadata[src]

impl Hash for PostMetadata[src]

impl Debug for PostMetadata[src]

Auto Trait Implementations

impl Send for PostMetadata

impl Unpin for PostMetadata

impl Sync for PostMetadata

impl UnwindSafe for PostMetadata

impl RefUnwindSafe for PostMetadata

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]