From 238cbb71e7cd537dfc32b3bc5e8c8153c761cc8f Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 5 Jun 2025 14:28:42 +0800 Subject: [PATCH] feat: implement dynamic title and description in HTML template - Updated index.html to use placeholders for title and description. - Enhanced vite.config.ts to transform HTML and replace placeholders with site configuration values. Signed-off-by: Innei --- apps/web/index.html | 7 ++++--- apps/web/vite.config.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/web/index.html b/apps/web/index.html index 84339923..6d4b4fb3 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -6,7 +6,8 @@ name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> - Photo Gallery + + {{TITLE}}
@@ -192,7 +193,7 @@ animation: titleSlide 1s ease-out; " > - Photo Gallery + {{TITLE}}
- Capturing moments, creating memories + {{DESCRIPTION}}

diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index b332d250..c3aec35f 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -52,6 +52,17 @@ export default defineConfig({ siteUrl: siteConfig.url, }), process.env.analyzer && analyzer(), + { + name: 'html-transform', + transformIndexHtml: { + enforce: 'pre', + transform(html: string) { + return html + .replaceAll('{{TITLE}}', siteConfig.title) + .replaceAll('{{DESCRIPTION}}', siteConfig.description) + }, + }, + }, ], define: { APP_DEV_CWD: JSON.stringify(process.cwd()),