+
排序
+ {
+ sortOptions.map((option) => (
+
+ {option.label}
+
+ ))
+ }
@@ -20,11 +119,19 @@ const devices = listDevices({ category: 'phone' });
>
-
{device.brand}
+
{device.model}
- {device.lifecycle === 'discontinued' ? '已停产' : device.lifecycle === 'announced' ? '已发布' : '在售'}
+ {device.lifecycle === 'discontinued'
+ ? '已停产'
+ : device.lifecycle === 'announced'
+ ? '已发布'
+ : '在售'}
@@ -48,7 +155,7 @@ const devices = listDevices({ category: 'phone' });
{
devices.length === 0 && (
- 暂无手机数据,运行 pnpm db:seed 写入种子数据。
+ 没有匹配的设备。试试清除关键词或换一个品牌。
)
}
diff --git a/src/pages/sitemap.xml.ts b/src/pages/sitemap.xml.ts
new file mode 100644
index 0000000..14f051c
--- /dev/null
+++ b/src/pages/sitemap.xml.ts
@@ -0,0 +1,23 @@
+import type { APIRoute } from 'astro';
+import { listBrands, listChips, listDevices } from '@/lib/repo';
+
+const SITE = 'https://specs.atie.fun';
+
+export const GET: APIRoute = () => {
+ const paths: string[] = ['', '/devices', '/chips', '/brands'];
+ for (const device of listDevices()) paths.push(`/devices/${device.slug}`);
+ for (const chip of listChips()) paths.push(`/chips/${chip.slug}`);
+ for (const item of listBrands()) paths.push(`/brands/${encodeURIComponent(item.brand)}`);
+
+ const body = `
+
+${paths.map((path) => ` ${SITE}${path}`).join('\n')}
+`;
+
+ return new Response(body, {
+ headers: {
+ 'content-type': 'application/xml; charset=utf-8',
+ 'cache-control': 'public, max-age=3600',
+ },
+ });
+};