From 70a3304dc146679550cc29f6598b809459c0c92b Mon Sep 17 00:00:00 2001 From: toom1996 Date: Wed, 16 Sep 2026 21:30:49 +0800 Subject: [PATCH] update --- src/components/RefineSidebar.astro | 4 +- .../{AccountPage.astro => Account.astro} | 0 src/components/views/ItemPage.astro | 157 ------------------ .../views/{LoginPage.astro => Login.astro} | 0 src/components/views/RunwayLooks.astro | 11 +- src/components/views/RunwayLooksDetail.astro | 0 src/components/views/StreetSnaps.astro | 5 +- src/components/views/StreetSnapsDetail.astro | 0 src/layouts/Layout.astro | 12 +- src/lib/ui.ts | 2 +- src/pages/cn/account.astro | 6 +- src/pages/cn/item/[id].astro | 12 -- src/pages/cn/login.astro | 6 +- src/pages/cn/runway-looks/[id].astro | 6 +- src/pages/cn/street-snaps/[id].astro | 6 +- src/pages/en/account.astro | 6 +- src/pages/en/item/[id].astro | 12 -- src/pages/en/login.astro | 6 +- src/pages/en/runway-looks/[id].astro | 6 +- src/pages/en/street-snaps/[id].astro | 6 +- src/pages/robots.txt.ts | 12 ++ src/pages/sitemap.xml.ts | 141 ++++++++++++++++ 22 files changed, 193 insertions(+), 223 deletions(-) rename src/components/views/{AccountPage.astro => Account.astro} (100%) delete mode 100644 src/components/views/ItemPage.astro rename src/components/views/{LoginPage.astro => Login.astro} (100%) create mode 100644 src/components/views/RunwayLooksDetail.astro create mode 100644 src/components/views/StreetSnapsDetail.astro delete mode 100644 src/pages/cn/item/[id].astro delete mode 100644 src/pages/en/item/[id].astro create mode 100644 src/pages/robots.txt.ts create mode 100644 src/pages/sitemap.xml.ts diff --git a/src/components/RefineSidebar.astro b/src/components/RefineSidebar.astro index 558ea6c..c713f1d 100644 --- a/src/components/RefineSidebar.astro +++ b/src/components/RefineSidebar.astro @@ -30,9 +30,9 @@ const { groups = [] } = Astro.props as { groups: Group[] } { groups.map((g) => (
-
+
{g.title} - +
diff --git a/src/components/views/AccountPage.astro b/src/components/views/Account.astro similarity index 100% rename from src/components/views/AccountPage.astro rename to src/components/views/Account.astro diff --git a/src/components/views/ItemPage.astro b/src/components/views/ItemPage.astro deleted file mode 100644 index 6ae9257..0000000 --- a/src/components/views/ItemPage.astro +++ /dev/null @@ -1,157 +0,0 @@ ---- -import Layout from "@/layouts/Layout.astro" -import RunwayLookCard from "@/components/RunwayLookCard.astro" -import StreetSnapCard from "@/components/StreetSnapCard.astro" -import { getSsrArticle, getSsrStreetSnap } from "@/lib/ssr" -import { getI18n } from "@/lib/i18n" -import { config } from '@/lib/config' - -// 按需 SSR:走秀(runway)与街拍(street snap)详情共用本视图,由页面按类型化路由透传 type。 -// 对外 id 已是「类型进密码、无前缀」编码(见后端 hashid.EncodeWithType);新类型化路由直接显式传 type。 -// 旧 /item/[id] 链接无 type 时回落到按 id 首字符嗅探(s=street),后端 Detail handler 对带 r=/s= 前缀的 -// 旧编码串有向后兼容回退(DecodeTyped),故历史外链仍能正确分流。 -// -// 本组件是 en/cn 两页的共享实现(语言由 Astro.currentLocale 运行时决定)。 -// 注意:`export const prerender = false` 必须留在**页面**文件里(Astro 只读页面模块的该导出), -// 故 id 由页面从 Astro.params 取出后作为 prop 透传进来。 -interface Props { - id?: string - type?: "runway" | "street" -} - -const { id, type } = Astro.props -// 优先用页面显式传入的 type(类型化路由);旧 /item/[id] 链接无 type 时按 id 前缀嗅探回退。 -const isSnap = type ? type === "street" : !!id && id[0] === "s" - -const { locale, t } = getI18n(Astro) - -let article = null -let articleErr = null -let snap = null -let snapErr = null -let preview = false -let imageTotal = 0 - -// await 必须位于 frontmatter 顶层(Astro 不支持块内顶层 await) -const data = isSnap - ? await getSsrStreetSnap(id, Astro.currentLocale) - : await getSsrArticle(id, Astro.currentLocale) - -// 用 in 收窄联合类型:isSnap 是运行时判断,TS 无法据此关联 data 的具体分支。 -if (isSnap) { - snap = "snap" in data ? data.snap : null - snapErr = data.error -} else { - article = "article" in data ? data.article : null - articleErr = data.error -} -preview = data.preview ?? false -imageTotal = data.imageTotal ?? 0 - -// 供客户端「收藏 / 历史」使用的精简元信息(服务端已拿到,直接透传,避免前端再发请求)。 -// id 优先取**接口回传的规范 id**(带类型前缀):用户若通过旧的无前缀链接进来(如 /item/0008CZYI), -// 也保证收藏 / 历史写入的是规范形式,不会与既有记录形成「同一篇文章两行」。 -const canonId = String((isSnap ? snap?.id : article?.id) ?? id ?? "") -const meta = isSnap - ? { id: canonId, type: "street", title: snap?.title ?? "", cover: snap?.cover ?? "", brand: "" } - : { id: canonId, type: "runway", title: article?.title ?? "", cover: article?.cover ?? "", brand: article?.brand_name ?? "" } - -// 详情页动态 TDK:标题用「品牌 + 系列」,描述/关键词按语言与类型生成(避免嵌套反引号,用拼接)。 -const SITE_NAME = config.siteName ?? "Xisoa" -const runwayName = article ? (article.brand_name + " " + article.title).trim() : "" -const baseName = isSnap ? (snap?.title || "") : runwayName -const detailTitle = baseName || SITE_NAME -const detailDesc = isSnap - ? (locale === 'cn' - ? `${baseName || SITE_NAME} —— 来自全球街头的时尚抓拍,收录于 ${SITE_NAME} 时尚档案。` - : `${baseName || SITE_NAME} — street style snaps from cities around the world, in the ${SITE_NAME} fashion archive.`) - : (locale === 'cn' - ? `${baseName || SITE_NAME} 走秀造型共 ${imageTotal} 张,查看细节图与系列信息,收录于 ${SITE_NAME} 时尚档案。` - : `${baseName || SITE_NAME} — ${imageTotal} runway looks with detail images and collection info, in the ${SITE_NAME} fashion archive.`) -const detailKeywords = isSnap - ? `${snap?.title || ''},street style,street snaps,fashion,${SITE_NAME}`.replace(/^,/, '') - : `${article?.brand_name || ''},runway,runway looks,fashion week,${SITE_NAME}`.replace(/^,/, '') - -const saveLabel = t("save") -const savedLabel = t("saved") ---- - - - {article ? : } - - - - -{(article || snap) && ( - -)} - -{/* 注意:不能用 define:vars 传 meta —— 它会把脚本包成内联 IIFE 并把 import 塞进函数体内, - 导致 SyntaxError(import 只能在模块顶层)。故改由 data-* 属性透传,脚本自行读取。 */} - diff --git a/src/components/views/LoginPage.astro b/src/components/views/Login.astro similarity index 100% rename from src/components/views/LoginPage.astro rename to src/components/views/Login.astro diff --git a/src/components/views/RunwayLooks.astro b/src/components/views/RunwayLooks.astro index d2ab809..4faa03d 100644 --- a/src/components/views/RunwayLooks.astro +++ b/src/components/views/RunwayLooks.astro @@ -4,9 +4,6 @@ import CollectionCard from "@/components/CollectionCard.astro" import RefineSidebar from "@/components/RefineSidebar.astro" import { getSsgHotBrands } from "@/lib/ssg" import { getI18n } from '@/lib/i18n' -import { getArticles, getBrands, type ArticleItem, type BrandEntry } from "@/lib/api" -import { makeCardSlots } from "@/lib/ui" -import { createCollectionPage } from "@/lib/collection-page" import "@/styles/look-grid.css" const { locale, t } = getI18n(Astro) @@ -95,7 +92,7 @@ const runwayGroups = [