整理目录

This commit is contained in:
2024-03-22 17:42:41 +08:00
parent 5a4efad893
commit fab9914f39
158 changed files with 158 additions and 84 deletions

View File

@ -19,8 +19,6 @@
--ifm-color-primary-lightest: #8abce5;
--ifm-code-font-size: 95%;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
--ifm-font-family-base: Roboto, "PingFang SC", "Microsoft Yahei", sans-serif;
--ifm-heading-font-family: Roboto, Verdana, "Raleway", "PingFang SC", "Microsoft Yahei", sans-serif;
}
/* For readability concerns, you should choose a lighter palette in dark mode. */

View File

@ -0,0 +1,73 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from "react";
import clsx from "clsx";
import { ThemeClassNames } from "@docusaurus/theme-common";
import { useDoc } from "@docusaurus/theme-common/internal";
import Heading from "@theme/Heading";
import MDXContent from "@theme/MDXContent";
import type { Props } from "@theme/DocItem/Content";
import { Detail } from "packages/docusaurus-plugin-content-docs-ex/src";
import dayjs from "dayjs";
/**
Title can be declared inside md content or declared through
front matter and added manually. To make both cases consistent,
the added title is added under the same div.markdown block
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
We render a "synthetic title" if:
- user doesn't ask to hide it with front matter
- the markdown content does not already contain a top-level h1 heading
*/
function useSyntheticTitle(): string | null {
const { metadata, frontMatter, contentTitle } = useDoc();
const shouldRender =
!frontMatter.hide_title && typeof contentTitle === "undefined";
if (!shouldRender) {
return null;
}
return metadata.title;
}
export default function DocItemContent({ children }: Props): JSX.Element {
const syntheticTitle = useSyntheticTitle();
const doc = useDoc();
const detail = (doc.metadata as any).detail as Detail;
return (
<div className={clsx(ThemeClassNames.docs.docMarkdown, "markdown")}>
{syntheticTitle && (
<header>
<Heading
as="h1"
style={{
marginBottom: "8px",
}}
>
{syntheticTitle}
</Heading>
{detail && (
<span
style={{
display: "block",
fontSize: "14px",
fontWeight: "normal",
marginBottom: "10px",
}}
>
{dayjs(detail.create_date).format("YYYY年MM月DD日")} · {" "}
{Math.ceil(detail.reading_time.minutes)}
</span>
)}
</header>
)}
<MDXContent>{children}</MDXContent>
</div>
);
}

View File

@ -1,43 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from "react";
import Heading from "@theme/Heading";
import type { Props } from "@theme/MDXComponents/Heading";
import { useDoc } from "@docusaurus/theme-common/internal";
import { Detail } from "packages/docusaurus-plugin-content-docs/src";
import dayjs from "dayjs";
export default function MDXHeading(props: Props): JSX.Element {
const doc = useDoc();
const detail = (doc.metadata as any).detail as Detail;
return (
<>
<Heading
{...props}
style={{
marginBottom: "6px",
}}
>
{props.children}
</Heading>
{detail && (
<span
style={{
display: "block",
fontSize: ".9rem",
fontWeight: "normal",
marginBottom: "1rem",
}}
>
{dayjs(detail.create_date).format("YYYY年MM月DD日")} · {" "}
{Math.ceil(detail.reading_time.minutes)}
</span>
)}
</>
);
}