From 067c136fe7ccc19aead294608984966c01423d2a Mon Sep 17 00:00:00 2001 From: jingrow Date: Wed, 3 Sep 2025 23:47:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DPresentation=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=97=A0=E6=B3=95=E5=8A=A0=E8=BD=BDmd=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=87=8C=E9=9D=A2=E7=9A=84theme=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/presentation/Presentation.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/presentation/Presentation.jsx b/components/presentation/Presentation.jsx index f29bfc4..e1875a2 100644 --- a/components/presentation/Presentation.jsx +++ b/components/presentation/Presentation.jsx @@ -5,6 +5,17 @@ import Reveal from 'reveal.js'; import 'reveal.js/dist/reveal.css'; import { marked } from 'marked'; +const parseThemeFromContent = (content) => { + if (!content || !content.startsWith('---')) return null; + + const frontmatterEnd = content.indexOf('---', 3); + if (frontmatterEnd === -1) return null; + + const frontmatter = content.substring(3, frontmatterEnd); + const themeMatch = frontmatter.match(/theme:\s*(\w+)/); + return themeMatch ? themeMatch[1] : null; +}; + const loadTheme = async (themeName) => { if (!themeName) return; @@ -152,7 +163,7 @@ export default function Presentation({ data }) { revealRef.current.destroy(); } - const themeName = data.theme || 'default'; + const themeName = data.theme || parseThemeFromContent(data.content) || 'default'; await loadTheme(themeName); revealRef.current = new Reveal(deckRef.current, REVEAL_CONFIG);