summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2025-04-14 12:45:28 -0400
committerAdam T. Carpenter <atc@53hor.net>2025-04-14 12:45:28 -0400
commit630003fff596f462d454a56223c02350d8b5543b (patch)
treef37b551ebf707378f55e99eec0cf07df8e759770 /src
parenta473319831b04b3d935f36ae98ebd5a9e83d4d7b (diff)
downloadcarpentertutoring-630003fff596f462d454a56223c02350d8b5543b.tar.xz
carpentertutoring-630003fff596f462d454a56223c02350d8b5543b.zip
feat: per-post open graph tags
Diffstat (limited to 'src')
-rw-r--r--src/posts/abstractions/post.rs1
-rw-r--r--src/posts/fs_post.rs12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/posts/abstractions/post.rs b/src/posts/abstractions/post.rs
index a941281..9667828 100644
--- a/src/posts/abstractions/post.rs
+++ b/src/posts/abstractions/post.rs
@@ -3,4 +3,5 @@ use std::{borrow::Cow, fmt};
pub trait Post: fmt::Debug + Ord {
fn get_title(&self) -> &str;
fn get_article(&self) -> Cow<str>;
+ fn get_description(&self) -> Cow<str>;
}
diff --git a/src/posts/fs_post.rs b/src/posts/fs_post.rs
index 8b8e725..8f1a435 100644
--- a/src/posts/fs_post.rs
+++ b/src/posts/fs_post.rs
@@ -21,6 +21,18 @@ impl Post for FsPost {
let article = fs::read_to_string(&self.file).unwrap();
Cow::Owned(article)
}
+
+ fn get_description(&self) -> Cow<str> {
+ let article = self.get_article();
+ Cow::Owned(
+ article
+ .split_once("\n")
+ .map(|(first, _)| first)
+ .unwrap_or_default()
+ .trim_start_matches('_')
+ .to_owned(),
+ )
+ }
}
impl Ord for FsPost {