From ae39d7b08ccd0ed15466f122972e9bbb1905ce17 Mon Sep 17 00:00:00 2001 From: radishzzz Date: Sun, 26 Jan 2025 02:59:39 +0000 Subject: [PATCH] feat: enhance post listing and reading time display - Implement dynamic post listing grouped by year with improved date formatting - Add reading time display for each post - Update index pages for both default and localized routes - Modify content utility functions to support reading time metadata - Refactor global styles and type definitions to support new features --- src/components/Header.astro | 15 +- ...angSwitch.astro => LanguageSwitcher.astro} | 44 +++-- src/components/Navbar.astro | 8 +- src/components/ThemeToggle.astro | 10 +- src/config.ts | 16 +- src/content/posts/hometown copy 2.md | 185 ++++++++++++++++++ src/content/posts/hometown copy.md | 185 ++++++++++++++++++ src/content/posts/hometown.md | 4 +- src/content/posts/rashomon.md | 2 +- src/layouts/Layout.astro | 2 +- src/pages/[lang]/index.astro | 51 +++-- src/pages/[lang]/posts/[slug].astro | 7 +- src/pages/index.astro | 43 ++-- src/pages/posts/[slug].astro | 7 +- src/styles/global.css | 55 +++--- src/types/global.d.ts | 10 +- src/utils/content.ts | 27 ++- src/utils/ui.ts | 4 +- 18 files changed, 558 insertions(+), 117 deletions(-) rename src/components/{LangSwitch.astro => LanguageSwitcher.astro} (60%) create mode 100644 src/content/posts/hometown copy 2.md create mode 100644 src/content/posts/hometown copy.md diff --git a/src/components/Header.astro b/src/components/Header.astro index 9867c76..fbca34c 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -2,9 +2,9 @@ import themeConfig from '@/config' const { title, subtitle } = themeConfig.site -const { titleSpace = 2 } = themeConfig.global +const { titleSpace } = themeConfig.global -const marginClass = { +const marginBottom = { 1: 'mb-1', 2: 'mb-2', 3: 'mb-3', @@ -13,18 +13,13 @@ const marginClass = { ---
-

+

{title}

-

+ +

{subtitle}

diff --git a/src/components/LangSwitch.astro b/src/components/LanguageSwitcher.astro similarity index 60% rename from src/components/LangSwitch.astro rename to src/components/LanguageSwitcher.astro index 14d5173..4fb3ea8 100644 --- a/src/components/LangSwitch.astro +++ b/src/components/LanguageSwitcher.astro @@ -6,26 +6,30 @@ const langs = ['', ...themeConfig.global.moreLocale] const currentLocale = themeConfig.global.locale function getLanguageDisplayName(code: string) { - if (!code) -return 'Default' + if (!code) { + return 'Default' + } return new Intl.DisplayNames(['en'], { type: 'language' }).of(code) || code } --- diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index a4e3ccf..fa1bc69 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -51,13 +51,13 @@ const isTagActive = isTagPage(currentPath) const isAboutActive = isAboutPage(currentPath) --- -