Repository navigation
Expand file tree
/
Copy pathsource.config.ts
More file actions
71 lines (64 loc) · 2.91 KB
/
Copy pathsource.config.ts
File metadata and controls
71 lines (64 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { metaSchema } from 'fumadocs-core/source/schema';
import { defineCollections, defineConfig, defineDocs } from 'fumadocs-mdx/config';
import { execFileSync } from 'node:child_process';
import { mdxOptions } from './lib/mdx-options.ts';
import { arbitrumPageSchema } from './lib/page-schema';
import { referenceSchema } from './lib/reference-schema';
// A shallow clone reports its oldest commit as adding every file, which would stamp most pages
// with one wrong date, so no date is resolved without full history. Vercel clones shallow unless
// `VERCEL_DEEP_CLONE=true` is set.
function hasFullGitHistory(): boolean {
try {
const out = execFileSync('git', ['rev-parse', '--is-shallow-repository'], {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
});
return out.trim() === 'false';
} catch {
return false;
}
}
// Never `false`: fumadocs-mdx types `page.data.lastModified` only while the option is truthy, so
// the fallback is a resolver that returns no date.
const lastModified = hasFullGitHistory() ? true : async () => undefined;
/**
* Partials live in `content/partials/`, outside the doc collection `dir`, so they can never be
* routed and need no glob exclusion here. Pages inline them with `<include cwd>…</include>`.
*/
export const docs = defineDocs({
dir: 'content/docs',
docs: {
// On-demand compilation: `next dev` compiles a page when it is first requested instead of
// every page before the first one renders. `page.data` keeps the frontmatter; `body`, `toc`,
// `lastModified` and the processed markdown come from `await page.data.load()`
// (fumadocs-mdx/runtime/dynamic.js). The production build prerenders every page as before.
// Dynamic mode forbids top-level `import`/`export` in MDX and relative image paths.
dynamic: true,
schema: arbitrumPageSchema,
postprocess: {
// The markdown mirrors and llms-full.txt, sliced from the authored source after the plugins
// in lib/mdx-options.ts have recorded their edits (lib/llms-markdown.ts).
includeProcessedMarkdown: true,
},
lastModified,
},
meta: {
schema: metaSchema,
},
});
/**
* Reference collections back the glossary hover references. Every entry shares `referenceSchema`
* ({ id, title, sortAs? }); the MDX body is the definition. A new reference type adds a collection
* with this schema plus one registry entry in `lib/references.ts`. A separate collection, so it
* does not carry the docs page contract; the schema lives in `lib/reference-schema.ts` because
* this file may only export collections.
*/
export const glossary = defineCollections({
type: 'doc',
dir: 'content/glossary',
// On demand like `docs`: the 167 entries otherwise compile with every route that renders a
// `<Term>`. The definition body comes from `await entry.load()` (lib/references.ts).
dynamic: true,
schema: referenceSchema,
});
export default defineConfig({ mdxOptions });