-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from opentofu/registry-docs-ui
Registry docs UI
- Loading branch information
Showing
18 changed files
with
443 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"title": "Overview", | ||
"path": "index.md", | ||
"slug": "" | ||
}, | ||
{ | ||
"title": "Users", | ||
"items": [ | ||
{ | ||
"title": "For user", | ||
"path": "users/index.md", | ||
"slug": "users" | ||
}, | ||
{ | ||
"title": "Using a module", | ||
"path": "users/modules.md", | ||
"slug": "users/modules" | ||
} | ||
] | ||
} | ||
] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { unified } from "unified"; | ||
import remarkParse from "remark-parse"; | ||
import remarkRehype from "remark-rehype"; | ||
import rehypeStringify from "rehype-stringify"; | ||
import announcement from "../../../announcement.md?raw"; | ||
|
||
export const content = unified() | ||
.use(remarkParse) | ||
.use(remarkRehype) | ||
.use(rehypeStringify) | ||
.processSync(announcement).value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,12 @@ | ||
import { useMemo } from "react"; | ||
import * as prod from "react/jsx-runtime"; | ||
|
||
import remarkFrontmatter from "remark-frontmatter"; | ||
import remarkParse from "remark-parse"; | ||
import remarkRehype from "remark-rehype"; | ||
import rehypeSlug from "rehype-slug"; | ||
import remarkGfm from "remark-gfm"; | ||
import rehypeReact, { Options } from "rehype-react"; | ||
import rehypeSanitize from "rehype-sanitize"; | ||
import rehypeRaw from "rehype-raw"; | ||
import { unified } from "unified"; | ||
import { MarkdownH1 } from "./H1"; | ||
import { MarkdownP } from "./P"; | ||
import { MarkdownPre } from "./Pre"; | ||
import { MarkdownH2 } from "./H2"; | ||
import { MarkdownH3 } from "./H3"; | ||
import { MarkdownCode } from "./Code"; | ||
import { MarkdownUl } from "./Ul"; | ||
import { MarkdownLi } from "./Li"; | ||
import { MarkdownA } from "./A"; | ||
import { MarkdownTable } from "./Table"; | ||
import { MarkdownTd } from "./Td"; | ||
import { MarkdownTh } from "./Th"; | ||
import { MarkdownImg } from "./Img"; | ||
import { MarkdownOl } from "./Ol"; | ||
import { MarkdownHr } from "./Hr"; | ||
|
||
const production: Options = { | ||
development: false, | ||
Fragment: prod.Fragment, | ||
jsx: prod.jsx, | ||
jsxs: prod.jsxs, | ||
components: { | ||
a: MarkdownA, | ||
ul: MarkdownUl, | ||
li: MarkdownLi, | ||
h1: MarkdownH1, | ||
h2: MarkdownH2, | ||
h3: MarkdownH3, | ||
p: MarkdownP, | ||
code: MarkdownCode, | ||
pre: MarkdownPre, | ||
table: MarkdownTable, | ||
td: MarkdownTd, | ||
th: MarkdownTh, | ||
img: MarkdownImg, | ||
ol: MarkdownOl, | ||
hr: MarkdownHr, | ||
}, | ||
}; | ||
import { processor } from "./processor"; | ||
|
||
interface MarkdownProps { | ||
text: string; | ||
} | ||
|
||
export function Markdown({ text }: MarkdownProps) { | ||
const { result } = useMemo( | ||
() => | ||
unified() | ||
.use(remarkParse) | ||
.use(remarkFrontmatter) | ||
.use(remarkGfm) | ||
.use(remarkRehype, { allowDangerousHtml: true }) // This is okay to use dangerous html because we are sanitizing later on in the pipeline | ||
.use(rehypeRaw) | ||
.use(rehypeSanitize) | ||
.use(rehypeSlug) | ||
.use(rehypeReact, production) | ||
.processSync(text), | ||
[text], | ||
); | ||
const { result } = useMemo(() => processor.processSync(text), [text]); | ||
|
||
return result; | ||
} |
Oops, something went wrong.