--- import { Image } from 'astro:assets'; import { getCollection } from 'astro:content'; import BaseLayout from '../layouts/BaseLayout.astro'; import IdCard from '../components/IdCard.astro'; import PostList from '../components/PostList.astro'; import ProjectWall from '../components/geek/ProjectWall.astro'; import Heatmap from '../components/geek/Heatmap.astro'; import { fetchHeartbeat, agoZh } from '../lib/heartbeat'; import { t } from '../i18n/ui'; import { homeConfig, homeTagline, renderMarkdown } from '../lib/site-content'; import SocialLinks from '../components/SocialLinks.astro'; // 首页可配项(后台主页设置):副标题/影像张数/区块开关/每轨条数,字段级回落 const cfg = await homeConfig('zh'); const subtitleHtml = cfg.subtitle ? await renderMarkdown(cfg.subtitle) : ''; const posts = (await getCollection('posts', ({ data }) => !data.draft && !data.tags.includes('hidden'))).sort( (a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime(), ); // 最新影像取集合前 4 张;照片时间序由照片管线(exif 车道)治理,此处只裁切 const photos = (await getCollection('photos')).slice(0, Math.max(1, cfg.latestPhotos)); const heartbeat = await fetchHeartbeat(); // 身份语改由 content/site/home.yaml 供给(后台可改),缺值回落默认文案 const tagline = await homeTagline('zh'); --- {tagline} {subtitleHtml && } {cfg.sections.tracks && } {cfg.sections.photos && cfg.latestPhotos > 0 && ( 最新影像 进入图库 → {photos.map((photo, i) => ( {/* 首两图 eager(Astro Image 默认 lazy 会把 LCP 压到 6s+),首图再拔 fetchpriority */} ))} )} {cfg.sections.heatmap && } {cfg.sections.projects && } {heartbeat && ( 最近心跳:{agoZh(heartbeat.when)} · {heartbeat.msg} )}
{tagline}
最近心跳:{agoZh(heartbeat.when)} · {heartbeat.msg}