pub struct Frontmatter {
pub title: Option<String>,
pub published: Option<String>,
pub cover: Option<String>,
pub model: Option<String>,
pub theme: Option<String>,
pub code: Option<String>,
pub description: String,
pub other: Value,
}Expand description
YAML frontmatter structure for markdown files.
This struct represents the frontmatter that can be present at the beginning
of markdown files. It supports common fields like title and published,
and uses #[serde(flatten)] to capture any additional fields.
§Examples
---
title: "My Article"
published: "draft"
author: "John Doe"
tags: ["rust", "wechat"]
theme: "lapis"
code: "github"
cover: "cover.png"
---Fields§
§title: Option<String>The title of the article. Optional field that will be omitted from serialization if not present.
published: Option<String>Publication status of the article.
Common values:
Noneor missing: not uploaded"draft": uploaded as draft to WeChat"true": published (will be skipped in directory mode)
cover: Option<String>Cover image filename for the article. If missing, the system will attempt to generate one using AI.
model: Option<String>Image generation model alias.
Available models: nb2 (default, Gemini Flash), nb (Gemini Pro), gpt (OpenAI)
theme: Option<String>Theme for the WeChat article styling.
Available themes: default, lapis, maize, orangeheart, phycat, pie, purple, rainbow
code: Option<String>Code highlighter for syntax highlighting.
Available highlighters: github, github-dark, vscode, atom-one-light, atom-one-dark, solarized-light, solarized-dark, monokai, dracula, xcode
description: StringDescription of the article.
other: ValueCaptures any additional fields in the frontmatter that are not explicitly defined in this struct.
Implementations§
Source§impl Frontmatter
impl Frontmatter
Sourcepub fn with_title(title: impl Into<String>) -> Self
pub fn with_title(title: impl Into<String>) -> Self
Creates a frontmatter with a title
Sourcepub fn set_published(&mut self, status: impl Into<String>)
pub fn set_published(&mut self, status: impl Into<String>)
Sets the published status
Sourcepub fn set_code_highlighter(&mut self, code: impl Into<String>)
pub fn set_code_highlighter(&mut self, code: impl Into<String>)
Sets the code highlighter
Sourcepub fn is_published(&self) -> bool
pub fn is_published(&self) -> bool
Checks if the article is published
Sourcepub fn is_unpublished(&self) -> bool
pub fn is_unpublished(&self) -> bool
Checks if the article is unpublished
Sourcepub fn effective_model(&self) -> &str
pub fn effective_model(&self) -> &str
Returns the effective model alias, defaulting to “nb2”
Trait Implementations§
Source§impl Clone for Frontmatter
impl Clone for Frontmatter
Source§fn clone(&self) -> Frontmatter
fn clone(&self) -> Frontmatter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Frontmatter
impl Debug for Frontmatter
Source§impl Default for Frontmatter
impl Default for Frontmatter
Source§fn default() -> Frontmatter
fn default() -> Frontmatter
Source§impl<'de> Deserialize<'de> for Frontmatter
impl<'de> Deserialize<'de> for Frontmatter
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Frontmatter
impl PartialEq for Frontmatter
Source§impl Serialize for Frontmatter
impl Serialize for Frontmatter
impl StructuralPartialEq for Frontmatter
Auto Trait Implementations§
impl Freeze for Frontmatter
impl RefUnwindSafe for Frontmatter
impl Send for Frontmatter
impl Sync for Frontmatter
impl Unpin for Frontmatter
impl UnsafeUnpin for Frontmatter
impl UnwindSafe for Frontmatter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().