From d72ec588377ab29ed6eff21f40c033a25d95d705 Mon Sep 17 00:00:00 2001 From: radishzzz Date: Sun, 26 Jan 2025 08:16:48 +0000 Subject: [PATCH] feat: add multilingual theme introduction posts - Added localized Retypeset theme introduction posts for multiple languages - Included posts in English, Spanish, Russian, Japanese, Chinese (Simplified and Traditional) - Standardized post structure with consistent metadata and content - Updated content configuration to support multilingual post entries --- src/components/LanguageSwitcher.astro | 1 - src/components/Navbar.astro | 6 - src/components/PhotoSwipe.astro | 20 ++- src/components/Scrollbar.astro | 4 +- src/components/ThemeToggle.astro | 7 +- src/content/config.ts | 26 ++-- src/content/posts/hometown copy 2.md | 185 -------------------------- src/content/posts/hometown copy.md | 185 -------------------------- src/content/posts/hometown.md | 185 -------------------------- src/content/posts/rashomon.md | 61 --------- src/content/posts/retypeset_en.md | 9 ++ src/content/posts/retypeset_es.md | 9 ++ src/content/posts/retypeset_ru.md | 9 ++ src/content/posts/retypeset_zh.md | 9 ++ src/content/posts/retyprset_ja.md | 9 ++ src/content/posts/retyprset_zh-tw.md | 9 ++ src/content/posts/容忍与自由.md | 63 +++++++++ src/content/posts/故乡.md | 183 +++++++++++++++++++++++++ src/content/posts/羅生門.md | 77 +++++++++++ src/pages/[lang]/index.astro | 2 +- src/pages/index.astro | 2 +- src/styles/global.css | 26 +++- src/styles/photoswipe.css | 4 + src/styles/scrollbar.css | 3 + 24 files changed, 425 insertions(+), 669 deletions(-) delete mode 100644 src/content/posts/hometown copy 2.md delete mode 100644 src/content/posts/hometown copy.md delete mode 100644 src/content/posts/hometown.md delete mode 100644 src/content/posts/rashomon.md create mode 100644 src/content/posts/retypeset_en.md create mode 100644 src/content/posts/retypeset_es.md create mode 100644 src/content/posts/retypeset_ru.md create mode 100644 src/content/posts/retypeset_zh.md create mode 100644 src/content/posts/retyprset_ja.md create mode 100644 src/content/posts/retyprset_zh-tw.md create mode 100644 src/content/posts/容忍与自由.md create mode 100644 src/content/posts/故乡.md create mode 100644 src/content/posts/羅生門.md diff --git a/src/components/LanguageSwitcher.astro b/src/components/LanguageSwitcher.astro index 4fb3ea8..e849e4e 100644 --- a/src/components/LanguageSwitcher.astro +++ b/src/components/LanguageSwitcher.astro @@ -55,7 +55,6 @@ function buildNewPath(currentLang, nextLang, segments, pathname) { if (currentLang) { segments[0] = nextLang || segments[0] - // Handle path with or without language code return nextLang ? `/${segments.join('/')}` : `/${segments.slice(1).join('/')}` diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index fa1bc69..23b5b76 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -2,15 +2,12 @@ import themeConfig from '@/config' import { ui } from '@/utils/ui' -// Configuration const defaultLocale = themeConfig.global.locale const moreLocales = themeConfig.global.moreLocale const currentPath = Astro.url.pathname -// Path utilities const cleanPath = (path: string) => path.replace(/^\/+|\/+$/g, '') -// Language utilities function getLangFromPath(path: string) { const secondaryLang = moreLocales.find(lang => path.startsWith(`/${lang}/`) || path === `/${lang}` || path === `/${lang}/`, @@ -21,13 +18,11 @@ function getLangFromPath(path: string) { const currentLang = getLangFromPath(currentPath) const currentUI = ui[currentLang as keyof typeof ui] -// Localization utilities function getLocalizedPath(path: string) { const clean = cleanPath(path) return currentLang === defaultLocale ? `/${clean}` : `/${currentLang}/${clean}` } -// Page type detection utilities function isHomePage(path: string) { const clean = cleanPath(path) return clean === '' || moreLocales.includes(clean) @@ -45,7 +40,6 @@ function isAboutPage(path: string) { return clean.startsWith('about') || moreLocales.some(lang => clean.startsWith(`${lang}/about`)) } -// Active state detection const isPostActive = isHomePage(currentPath) || isPostPage(currentPath) const isTagActive = isTagPage(currentPath) const isAboutActive = isAboutPage(currentPath) diff --git a/src/components/PhotoSwipe.astro b/src/components/PhotoSwipe.astro index c18e8c6..e2b1b8d 100644 --- a/src/components/PhotoSwipe.astro +++ b/src/components/PhotoSwipe.astro @@ -2,11 +2,16 @@ import PhotoSwipeLightbox from 'photoswipe/lightbox' import 'photoswipe/style.css' - // Store lightbox instance for later use let lightbox: PhotoSwipeLightbox | null = null const pswp = import('photoswipe') - // Initialize PhotoSwipe lightbox with custom configuration + function cleanup() { + if (lightbox) { + lightbox.destroy() + lightbox = null + } + } + function createPhotoSwipe() { // Clean up existing instance if any cleanup() @@ -24,7 +29,7 @@ doubleTapAction: 'zoom', }) - // Add custom filter to handle image data and dimensions + // Automatically add image dimensions lightbox.addFilter('domItemData', (itemData: any, element: Element) => { if (element instanceof HTMLImageElement) { itemData.src = element.src @@ -38,15 +43,6 @@ lightbox.init() } - // Cleanup function to destroy lightbox instance - function cleanup() { - if (lightbox) { - lightbox.destroy() - lightbox = null - } - } - - // Initialize PhotoSwipe when DOM is ready and after page transitions document.addEventListener('astro:page-load', createPhotoSwipe) document.addEventListener('astro:before-swap', cleanup) diff --git a/src/components/Scrollbar.astro b/src/components/Scrollbar.astro index 845128b..12c8e14 100644 --- a/src/components/Scrollbar.astro +++ b/src/components/Scrollbar.astro @@ -1,10 +1,8 @@