🚀 refactor: redesign the layout, reduce page size, and significantly improve build speed

This commit is contained in:
radishzzz 2025-03-22 03:45:15 +00:00
parent 89e1359bb5
commit 51ae238192
18 changed files with 390 additions and 486 deletions

View file

@ -0,0 +1,64 @@
---
import themeConfig from '@/config'
import { ui } from '@/i18n/ui'
import { getPageInfo } from '@/utils/page'
const { currentLang, getLocalizedPath, isPost } = getPageInfo(Astro.url.pathname)
const { title, subtitle, i18nTitle } = themeConfig.site
const { titleGap } = themeConfig.global
const currentUI = ui[currentLang as keyof typeof ui]
const headerTitle = i18nTitle ? currentUI.title : title
const headerSubtitle = i18nTitle ? currentUI.subtitle : subtitle
const marginBottom = {
1: 'mb-0.9',
2: 'mb-1.8',
3: 'mb-2.7',
}[titleGap] || 'mb-1.8 '
const postMarginBottom = {
1: 'mb-1.9 lg:mb-0.9',
2: 'mb-2.8 lg:mb-1.8',
3: 'mb-3.7 lg:mb-2.7',
}[titleGap] || 'mb-2.8 lg:mb-1.8'
const TitleTag = isPost ? 'h2' : 'h1'
const SubtitleTag = isPost ? 'div' : 'h2'
---
<header
class="mb-10.5"
lg="uno-desktop-column top-20"
>
<TitleTag
class:list={[
isPost
? `${postMarginBottom} mt-3.2 text-5.375 c-secondary lg:(mt-0 text-9 c-primary)`
: `${marginBottom} text-8 w-75% c-primary lg:(text-9 w-full)`,
'font-bold font-title',
]}
>
<a
href={getLocalizedPath('/')}
transition:name={`site-title-${currentLang}`}
data-disable-transition-on-theme
>
{headerTitle}
</a>
</TitleTag>
{headerSubtitle && (
<SubtitleTag
class:list={[
isPost
? `opacity-0 lg:opacity-100`
: 'w-75% text-balance lg:w-full',
'c-secondary font-navbar text-3.5 lg:text-4',
]}
aria-hidden={isPost}
>
{headerSubtitle}
</SubtitleTag>
)}
</header>