-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmdx-components.js
More file actions
54 lines (51 loc) · 1.81 KB
/
Copy pathmdx-components.js
File metadata and controls
54 lines (51 loc) · 1.81 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
import { Mermaid } from "nextra/components";
import { useMDXComponents as getThemeComponents } from "nextra-theme-docs";
import { CollectiveDocsSection } from "./components/home/CollectiveDocsSection";
import { HeroSection } from "./components/home/HeroSection";
import { ProjectCardsSection } from "./components/home/ProjectCardsSection";
import { QuickLinksSection } from "./components/home/QuickLinksSection";
import { ProjectList } from "./components/ProjectList";
import {
CardHover,
SectionReveal,
StaggerContainer,
StaggerItem,
} from "./components/ui/motion";
import { WhitepaperMetaInline } from "./components/WhitepaperMeta";
// Get the default MDX components
const themeComponents = getThemeComponents();
// H1 override: render the theme's normal H1, then render whitepaper metadata
// (proposer / status / review window) directly below it when present.
// On non-whitepaper pages there is no metadata context, so nothing is added.
function H1WithMeta(props) {
const ThemeH1 = themeComponents.h1 ?? "h1";
return (
<>
<ThemeH1 {...props} />
<WhitepaperMetaInline />
</>
);
}
// Merge components
export function useMDXComponents(components) {
return {
...themeComponents,
h1: H1WithMeta,
// Nextra's remark pipeline rewrites ```mermaid fences into <Mermaid /> but
// the docs theme does not supply the component, so every page must provide
// it or prerendering throws "Expected component `Mermaid` to be defined".
// Project docs are fetched from their own repos at build time, so any repo
// adding a mermaid diagram would otherwise break this build.
Mermaid,
ProjectList,
HeroSection,
QuickLinksSection,
ProjectCardsSection,
CollectiveDocsSection,
SectionReveal,
StaggerContainer,
StaggerItem,
CardHover,
...components,
};
}