diff --git a/src/components/RandomMemory.astro b/src/components/RandomMemory.astro new file mode 100644 index 0000000..cfa24f2 --- /dev/null +++ b/src/components/RandomMemory.astro @@ -0,0 +1,114 @@ +--- +import { articles } from "../data/articles"; +import { photoTopics } from "../data/photos"; +import { timeline } from "../data/timeline"; + +const memoryGroups = [ + { + type: "photo", + items: photoTopics.flatMap((topic) => + topic.photos + .filter((photo) => photo.image) + .map((photo) => ({ + href: photo.image, + title: photo.title, + caption: [topic.title, photo.caption].filter(Boolean).join(" · ") + })) + ) + }, + { + type: "article", + items: articles.map((article) => ({ + href: article.sourceUrl, + title: article.title + })) + }, + { + type: "timeline", + items: timeline.map((moment, index) => ({ + href: `/timeline/#moment-${index + 1}`, + title: `${moment.date} · ${moment.title}` + })) + } +]; +--- + + +随机打开一张照片、一篇文章或一个时间节点 + + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index ea81d9c..f54edac 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,6 +1,7 @@ --- import BaseLayout from "../layouts/BaseLayout.astro"; import OnThisDay from "../components/OnThisDay.astro"; +import RandomMemory from "../components/RandomMemory.astro"; import { galleryIntro, photoTopics } from "../data/photos"; import { featuredMessage, messages, messagesIntro } from "../data/messages"; import { people, peopleIntro } from "../data/people"; @@ -25,6 +26,7 @@ const previewPeople = people.slice(0, 6);
{site.subtitle}
diff --git a/src/pages/timeline.astro b/src/pages/timeline.astro index c75a253..8af2dc5 100644 --- a/src/pages/timeline.astro +++ b/src/pages/timeline.astro @@ -19,9 +19,9 @@ import { timeline, timelineIntro } from "../data/timeline";