diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-24 14:09:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-24 14:09:38 +0100 |
| commit | 448844d66cef5f4980d0575e783757264c962bb5 (patch) | |
| tree | f280aaef927da2a30c18f13cc124c8eb77ad3abf /library/src/meta/document.rs | |
| parent | 6547c2d6d5b25f44e52ac56698ed08ff6a5dbb3a (diff) | |
Allow multiple authors
Diffstat (limited to 'library/src/meta/document.rs')
| -rw-r--r-- | library/src/meta/document.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/library/src/meta/document.rs b/library/src/meta/document.rs index 32e944dc..1d349b89 100644 --- a/library/src/meta/document.rs +++ b/library/src/meta/document.rs @@ -25,9 +25,9 @@ impl DocumentNode { #[property(referenced)] pub const TITLE: Option<EcoString> = None; - /// The document's author. + /// The document's authors. #[property(referenced)] - pub const AUTHOR: Option<EcoString> = None; + pub const AUTHOR: Author = Author(vec![]); } impl LayoutRoot for DocumentNode { @@ -43,7 +43,7 @@ impl LayoutRoot for DocumentNode { Ok(Document { pages, title: styles.get(Self::TITLE).clone(), - author: styles.get(Self::AUTHOR).clone(), + author: styles.get(Self::AUTHOR).0.clone(), }) } } @@ -54,3 +54,13 @@ impl Debug for DocumentNode { self.0.fmt(f) } } + +/// A list of authors. +#[derive(Debug, Clone, Hash)] +pub struct Author(Vec<EcoString>); + +castable! { + Author, + v: EcoString => Self(vec![v]), + v: Array => Self(v.into_iter().map(Value::cast).collect::<StrResult<_>>()?), +} |
