mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: cleaner api rendering
This commit is contained in:
1 parent
8b01b7c192
commit
0e57943d33
5 files changed
+28
-9
No files matched your search
@@ -120,6 +120,7 @@
|
|||||||
"api": {
|
"api": {
|
||||||
"json": "JSON methods",
|
"json": "JSON methods",
|
||||||
"pb": "Protocol Buffer methods",
|
"pb": "Protocol Buffer methods",
|
||||||
"media": "Media methods"
|
"media": "Media methods",
|
||||||
|
"no_docs": "This method has no documentation."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
---
|
---
|
||||||
import type { CollectionEntry } from "astro:content";
|
import type { CollectionEntry } from "astro:content";
|
||||||
|
import { api } from "../core/api/dynamic";
|
||||||
import { Code } from "./Code";
|
import { Code } from "./Code";
|
||||||
import { Heading } from "./Heading";
|
import { Heading } from "./Heading";
|
||||||
import { MarkdownCustom } from "./MarkdownCustom";
|
import { MarkdownCustom } from "./MarkdownCustom";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
locale: string;
|
||||||
apis: CollectionEntry<"api">[];
|
apis: CollectionEntry<"api">[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const { apis } = Astro.props;
|
const { apis, locale } = Astro.props;
|
||||||
|
const strings = await api.strings(locale);
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -16,6 +19,10 @@ const { apis } = Astro.props;
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var(--space-4);
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
.docs {
|
||||||
|
margin-left: var(--space-5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -28,7 +35,10 @@ const { apis } = Astro.props;
|
|||||||
<Code>{api.id}</Code>
|
<Code>{api.id}</Code>
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
<MarkdownCustom body={api.data.docs ?? ""} />
|
<MarkdownCustom
|
||||||
|
className="docs"
|
||||||
|
body={api.data.docs ?? strings.api.no_docs}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
|
import type { ComponentProps } from "react";
|
||||||
import Markdown from "react-markdown";
|
import Markdown from "react-markdown";
|
||||||
|
import { classNames } from "../../core/ui/classNames";
|
||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface Props {
|
interface MarkdownCustom extends ComponentProps<"div"> {
|
||||||
body: string;
|
body: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MarkdownCustom({ body }: Props) {
|
export function MarkdownCustom({ body, className, ...props }: MarkdownCustom) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.markdown}>
|
<div className={classNames(className, styles.markdown)} {...props}>
|
||||||
<Markdown
|
<Markdown
|
||||||
components={{
|
components={{
|
||||||
p: Text,
|
p: Text,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
|
|||||||
<style>
|
<style>
|
||||||
.tool-banner {
|
.tool-banner {
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
margin-bottom: var(--space-4);
|
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -28,17 +28,24 @@ paths.sort((a, b) => a.path.localeCompare(b.path));
|
|||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<Heading>{strings.api.json}</Heading>
|
<Heading>{strings.api.json}</Heading>
|
||||||
<ApiGroup apis={collection.filter((api) => api.id.endsWith(".json"))} />
|
<ApiGroup
|
||||||
|
{locale}
|
||||||
|
apis={collection.filter((api) => api.id.endsWith(".json"))}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<Heading>{strings.api.pb}</Heading>
|
<Heading>{strings.api.pb}</Heading>
|
||||||
<ApiGroup apis={collection.filter((api) => api.id.endsWith(".pb"))} />
|
<ApiGroup
|
||||||
|
{locale}
|
||||||
|
apis={collection.filter((api) => api.id.endsWith(".pb"))}
|
||||||
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
<Heading>{strings.api.media}</Heading>
|
<Heading>{strings.api.media}</Heading>
|
||||||
<ApiGroup
|
<ApiGroup
|
||||||
|
{locale}
|
||||||
apis={collection.filter(
|
apis={collection.filter(
|
||||||
(api) => !api.id.endsWith(".json") && !api.id.endsWith(".pb"),
|
(api) => !api.id.endsWith(".json") && !api.id.endsWith(".pb"),
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in new issue
Block a user