Skip to content

Commit

Permalink
Don't serialize Nones in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Aug 29, 2024
1 parent a0db613 commit 2ef6d90
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/core/src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,11 @@ pub(crate) struct FileMetadata {
pub draft: bool,
pub slug: String,
pub path: Utf8PathBuf,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub date: Option<HinokiDatetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub repeat: Option<Repeat>,
pub extra: IndexMap<String, toml::Value>,

Expand Down Expand Up @@ -505,9 +508,13 @@ fn render(
struct MetadataContext<'a> {
source_dir: &'a Utf8Path,
source_file_stem: &'a str,
#[serde(skip_serializing_if = "Option::is_none")]
slug: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
title: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
date: Option<HinokiDatetime>,
#[serde(skip_serializing_if = "Option::is_none")]
repeat: Option<&'a Repeat>,
}

Expand Down

0 comments on commit 2ef6d90

Please sign in to comment.