Skip to content

Commit 6c947e3

Browse files
authored
Merge pull request #53 from tsugumi-sys/feat/ogp
feat: support ogp
2 parents cb46814 + 802bd68 commit 6c947e3

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html/src/post.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::metadata::Post;
22

33
pub fn post_html(
44
post: &Post,
5+
site_title: &str,
56
aside_html: &str,
67
footer_html: &str,
78
icon_html: &str,
@@ -26,13 +27,18 @@ pub fn post_html(
2627
);
2728

2829
// Final HTML assembly
30+
let og_description = post.meta.tldr.as_deref().unwrap_or(site_title);
2931
format!(
3032
r#"<!DOCTYPE html>
3133
<html lang="en">
3234
<head>
3335
<meta charset="UTF-8" />
3436
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
3537
<title>{title}</title>
38+
<meta property="og:title" content="{og_title}" />
39+
<meta property="og:description" content="{og_description}" />
40+
<meta property="og:type" content="article" />
41+
<meta property="og:site_name" content="{site_title}" />
3642
<link rel="stylesheet" href="{css_file_path}">
3743
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css">
3844
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-core.min.js"></script>
@@ -61,6 +67,9 @@ pub fn post_html(
6167
</html>
6268
"#,
6369
title = post.meta.title,
70+
og_title = post.meta.title,
71+
og_description = og_description,
72+
site_title = site_title,
6473
css_file_path = css_file_path,
6574
icon_html = icon_html,
6675
aside_html = aside_html,

mejiro-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mejiro-cli"
3-
version = "0.1.21"
3+
version = "0.1.22"
44
edition = "2024"
55
description = "A CLI tool for Mejiro"
66
license = "MIT OR Apache-2.0"

mejiro-cli/src/compile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn compile(input_dir: &str, output_dir: &str, config_path: &str) {
7171
build_post_pages(
7272
&posts,
7373
Path::new(output_dir),
74+
&config.site_title,
7475
&aside,
7576
&footer,
7677
&icon,
@@ -167,6 +168,7 @@ fn copy_images(src_dir: &Path, dest_dir: &Path) {
167168
fn build_post_pages(
168169
posts: &[Post],
169170
output_dir: &Path,
171+
site_title: &str,
170172
aside: &str,
171173
footer: &str,
172174
icon: &str,
@@ -179,7 +181,7 @@ fn build_post_pages(
179181
fs::create_dir_all(output_path.parent().unwrap()).unwrap();
180182

181183
let css_relative_path = format!("../{css_filename}");
182-
let post_html = html::post_html(post, aside, footer, icon, &css_relative_path);
184+
let post_html = html::post_html(post, site_title, aside, footer, icon, &css_relative_path);
183185
fs::write(&output_path, post_html).unwrap();
184186
}
185187
}

0 commit comments

Comments
 (0)