{{ post.title }}
- {{ post.formatted_date }} ·
{{{ post.author }}}
+ {{ post.formatted_date }} ·
{{{ post.author }}}
{{{ post.content }}}
diff --git a/src/app.rs b/src/app.rs
index 9bd14aa..8e9b666 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -62,9 +62,15 @@ impl App<'_> {
pub fn data(&self, mut value: Value) -> Result {
let mut map = Map::::new();
+ map.insert("site".into(), self.manifest.site.clone().into());
map.insert("title".into(), self.manifest.title.clone().into());
map.insert("base".into(), self.manifest.base.clone().into());
- map.insert("ximage".into(), self.manifest.ximage.clone().into());
+ map.insert("image".into(), self.manifest.image.clone().into());
+ map.insert("twitter".into(), self.manifest.site.clone().into());
+ map.insert(
+ "favicon".into(),
+ format!("/{}", self.manifest.favicon.file_name()?).into(),
+ );
map.insert(
"description".into(),
self.manifest.description.clone().into(),
@@ -74,13 +80,6 @@ impl App<'_> {
map.insert("livereload".into(), LIVERELOAD_ENDPOINT.into());
}
- if self.manifest.favicon.exists() {
- map.insert(
- "favicon".into(),
- format!("/{}", self.manifest.favicon.file_name()?).into(),
- );
- }
-
if let Some(data) = value.as_object_mut() {
map.append(data);
}
@@ -112,14 +111,11 @@ impl App<'_> {
} else if self.manifest.public.exists() && self.manifest.public.is_sub(&path)? {
tracing::trace!("copying public: {path:?} ...");
self.manifest.copy_public()?;
- } else if self.manifest.favicon.exists() && self.manifest.favicon.is_sub(&path)? {
- tracing::trace!("rendering favicon: {path:?} ...");
- self.render_favicon()?;
} else if self.manifest.templates.exists() && self.manifest.templates.is_sub(&path)? {
tracing::info!("reloading templates ...");
templates_changed = true;
self.register_templates()?;
- } else {
+ } else if self.manifest.favicon.exists() && self.manifest.favicon == path {
tracing::trace!("skipping {path:?} ...");
}
}
@@ -181,6 +177,8 @@ impl App<'_> {
serde_json::json!({
"post": post,
"tab": post.meta.title,
+ "description": post.meta.description,
+ "twitter": post.meta.twitter,
}),
)
}
diff --git a/src/manifest.rs b/src/manifest.rs
index 04adc3f..3f549b1 100644
--- a/src/manifest.rs
+++ b/src/manifest.rs
@@ -26,6 +26,11 @@ title = "sonata"
#[derive(Debug, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "cli", derive(Parser))]
pub struct Manifest {
+ /// The site name.
+ #[serde(default = "default::site")]
+ #[cfg_attr(feature = "cli", clap(long, default_value = ""))]
+ pub site: String,
+
/// The name of the site.
#[cfg_attr(feature = "cli", clap(long, default_value = "sonata"))]
pub title: String,
@@ -65,9 +70,9 @@ pub struct Manifest {
#[cfg_attr(feature = "cli", clap(short, long, default_value = "templates"))]
pub templates: PathBuf,
- #[serde(default = "default::ximage")]
+ #[serde(default = "default::image")]
#[cfg_attr(feature = "cli", clap(short, long, default_value = "ximage"))]
- pub ximage: String,
+ pub image: String,
/// The path of the theme.
///
@@ -208,9 +213,10 @@ impl Manifest {
impl Default for Manifest {
fn default() -> Self {
Self {
+ site: "sonata".to_string(),
title: "sonata".to_string(),
base: "".to_string(),
- ximage: "".to_string(),
+ image: "".to_string(),
description: "".to_string(),
favicon: default::favicon(),
out: default::out(),
@@ -233,12 +239,18 @@ mod default {
/// The default theme.
pub const DEFAULT_THEME: &str = include_str!("../blog/theme/theme.css");
+ /// Default implementation of the site name.
+ pub fn site() -> String {
+ "".to_string()
+ }
+
/// Default implementation of the base URL.
pub fn base() -> String {
"/".to_string()
}
- pub fn ximage() -> String {
+ /// Default implementation of the image.
+ pub fn image() -> String {
"".to_string()
}
diff --git a/src/post.rs b/src/post.rs
index 5ba41f1..18e6013 100644
--- a/src/post.rs
+++ b/src/post.rs
@@ -121,7 +121,7 @@ pub struct Meta {
pub author: String,
/// The profile url of the author.
#[serde(default)]
- pub profile_url: String,
+ pub twitter: String,
/// The date of the post.
#[serde(default)]
pub date: NaiveDate,