@ -1,27 +1,15 @@
|
||||
---
|
||||
import Layout from "@/layouts/Layout.astro"
|
||||
import Article from "@/components/pages/article.astro"
|
||||
import { fetchArticleById } from "@/lib/data"
|
||||
import { getSsrArticle } from "@/lib/ssr"
|
||||
|
||||
// 按需 SSR:服务端按 ?id= 取数并渲染(保留既有 /cn/article?id= 链接,无需改动其他页面)
|
||||
export const prerender = false
|
||||
|
||||
const API = (import.meta.env.API_SSR || import.meta.env.PUBLIC_API_BASE || "http://localhost:8090").replace(/\/$/, "")
|
||||
const id = Astro.url.searchParams.get("id")
|
||||
let article: import("@/lib/data").RawArticle | null = null
|
||||
let error: "missing" | "failed" | null = null
|
||||
if (!id) {
|
||||
error = "missing"
|
||||
} else {
|
||||
try {
|
||||
article = await fetchArticleById(id, API)
|
||||
} catch {
|
||||
article = null
|
||||
}
|
||||
error = article ? null : "failed"
|
||||
}
|
||||
const { article, error } = await getSsrArticle(id)
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<Article article={article} locale="cn" apiBase={API} error={error} />
|
||||
<Article article={article} locale="cn" error={error} />
|
||||
</Layout>
|
||||
|
||||
@ -2,7 +2,10 @@
|
||||
import Layout from "@/layouts/Layout.astro"
|
||||
import Breadcrumb from "@/components/Breadcrumb.astro"
|
||||
import { getBrands, getYears, type BrandEntry } from "@/lib/api"
|
||||
import { getI18n } from '@/i18n/utils'
|
||||
import { clientHref, PATH, href } from '@/lib/routes'
|
||||
|
||||
const { locale } = getI18n(Astro)
|
||||
let sidebarBrands: BrandEntry[] = []
|
||||
let yearChips: number[] = []
|
||||
|
||||
@ -21,14 +24,14 @@ if (!yearChips.length) yearChips = yearSeed
|
||||
---
|
||||
|
||||
<Layout title="All Shows — Portfolio Studio">
|
||||
<div class="showsroot w-full" x-data="showsPage()">
|
||||
<div class="showsroot w-full" x-data="showsPage()" data-locale={locale}>
|
||||
<!-- 顶部:极简眉头 -->
|
||||
<header class="showshead">
|
||||
<div>
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ label: 'Home', href: '/' },
|
||||
{ label: 'Runway Archive', href: '/shows' },
|
||||
{ label: 'Home', href: href(locale, PATH.home) },
|
||||
{ label: 'Runway Archive', href: href(locale, PATH.shows) },
|
||||
]}
|
||||
>
|
||||
<span slot="current" x-text="crumbYear">2026 Edition</span>
|
||||
@ -187,7 +190,7 @@ if (!yearChips.length) yearChips = yearSeed
|
||||
|
||||
<!-- Card List -->
|
||||
<template x-for="it in items" :key="it.id">
|
||||
<a class="showscard" :href="`/article?id=${it.id}`" :aria-label="`${it.brand_name} ${it.title}`">
|
||||
<a class="showscard" :href="articleHref(it)" :aria-label="`${it.brand_name} ${it.title}`">
|
||||
<div class="showscard-left">
|
||||
<div class="showscard-img" :class="{ 'is-loaded': it._imgLoaded }">
|
||||
<span class="showsspin" aria-hidden="true" x-html="SPIN_SVG"></span>
|
||||
@ -557,6 +560,7 @@ if (!yearChips.length) yearChips = yearSeed
|
||||
|
||||
return {
|
||||
allBrands,
|
||||
locale: '',
|
||||
ICON_USER,
|
||||
ICON_DATE,
|
||||
SPIN_SVG,
|
||||
@ -594,6 +598,7 @@ if (!yearChips.length) yearChips = yearSeed
|
||||
reqToken: 0,
|
||||
|
||||
init() {
|
||||
this.locale = this.$el.dataset.locale || 'en'
|
||||
this.loadPage(1, false)
|
||||
},
|
||||
|
||||
@ -826,6 +831,7 @@ if (!yearChips.length) yearChips = yearSeed
|
||||
|
||||
// 辅助辅助工具函数
|
||||
toAbsUrl(url: string) { return toAbs(url) },
|
||||
articleHref(it: { id: string | number }) { return clientHref(this.locale, PATH.article(it.id)) },
|
||||
isNewAdded(pubAt?: number) { return Date.now() / 1000 - Number(pubAt || 0) < 60 * 60 * 24 * 14 },
|
||||
fmtDate(ts: number) {
|
||||
if (!ts) return ""
|
||||
|
||||
Reference in New Issue
Block a user