import type { GetServerSideProps, InferGetServerSidePropsType } from "next"; import Head from "next/head"; import Link from "next/link"; import { useState } from "react"; import { listDocs, type DocLink } from "@/lib/docs"; import { Shell, Navigation } from "@/components/Shell"; import { Icon } from "@/components/Icon"; import { collectionEntries, collectionIcon, collectionLabel, collectionTone } from "@/lib/collections"; export const getServerSideProps: GetServerSideProps<{ docs: DocLink[] }> = async ({ res }) => { res.setHeader("Cache-Control", "private, no-store"); return { props: { docs: await listDocs() } }; }; const PAGE_SIZE = 8; export default function Home({ docs }: InferGetServerSidePropsType) { const [collection, setCollection] = useState(""); const [query, setQuery] = useState(""); const [page, setPage] = useState(0); const collections = [...new Set(docs.map((doc) => doc.collection))]; const filtered = docs.filter((doc) => (!collection || doc.collection === collection) && `${doc.title} ${doc.description}`.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())); const entries = collectionEntries(docs); return <> Tabularium · 资料库

文档中心

系统设计、源码研究与学习笔记。

{entries.map(({ name, entry, count }) =>

{collectionLabel(name)}

{entry.description}

{count} 篇 )}

全部资料

{["", ...collections].map((name) => )}
    {filtered.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE).map((doc) =>
  • {doc.title.replace("(草案)", "")}{doc.draft && 草案}{doc.group}
  • )}
{filtered.length === 0 &&

没有找到相关资料。

} {filtered.length > PAGE_SIZE && }
; }