From 3d4a16867677efe688d7e0cc4ee32f06198f0a40 Mon Sep 17 00:00:00 2001 From: st1020 Date: Sat, 18 May 2024 18:20:43 +0800 Subject: [PATCH] feat: add Open Graph protocol support --- config.toml | 2 ++ templates/partials/head.html | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/config.toml b/config.toml index 8cd3ec9..6b64ddb 100644 --- a/config.toml +++ b/config.toml @@ -50,6 +50,8 @@ math = false mermaid = false # Enable comment support globally. comment = false +# The URL of social image. +social_image = "icons/github.svg" [extra.style] # The custom background color. diff --git a/templates/partials/head.html b/templates/partials/head.html index 1babf07..63d12e4 100644 --- a/templates/partials/head.html +++ b/templates/partials/head.html @@ -11,13 +11,40 @@ - {% if page %} - - + + {% set page_title = page.title | default(value=config.title) %} + + {% set description = page.summary | default(value=page_title) %} + + + + + + + + + {% set image = page.extra.cover_image | default(value=config.extra.social_image) %} + + {% if image %} + + {% endif %} + {% else %} - + + {% set description = config.description | default(value="A personal blog") %} + + + + + + + + {% if config.extra.social_image %} + + {% endif %} + {% endif %}