This commit is contained in:
parent
e9c32c4118
commit
ead6e839df
@ -37,6 +37,15 @@ const config: Config = {
|
|||||||
],
|
],
|
||||||
["docusaurus-plugin-docs-info", { debug: true }],
|
["docusaurus-plugin-docs-info", { debug: true }],
|
||||||
],
|
],
|
||||||
|
markdown: {
|
||||||
|
preprocessor({ filePath, fileContent }) {
|
||||||
|
// 去掉第一行的#标题,因为不去掉的话会导致创建时间和阅读时间的错误
|
||||||
|
if (fileContent.startsWith("# ")) {
|
||||||
|
return fileContent.replace(/^# (.+?)[\r\n]+/, "");
|
||||||
|
}
|
||||||
|
return fileContent;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// Even if you don't use internationalization, you can use this field to set
|
// Even if you don't use internationalization, you can use this field to set
|
||||||
// useful metadata like html lang. For example, if your site is Chinese, you
|
// useful metadata like html lang. For example, if your site is Chinese, you
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import Heading from "@theme-original/Heading";
|
|
||||||
import { useSyntheticTitle } from "../DocItem/Content";
|
|
||||||
import { useDoc } from "@docusaurus/theme-common/internal";
|
|
||||||
import dayjs from "dayjs";
|
|
||||||
import { Detail } from "docusaurus-plugin-content-docs-ex/src";
|
|
||||||
|
|
||||||
export default function HeadingWrapper(props) {
|
|
||||||
const syntheticTitle = useSyntheticTitle();
|
|
||||||
const doc = useDoc();
|
|
||||||
const detail = (doc.metadata as any).detail as Detail;
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Heading {...props}>
|
|
||||||
{props.children}
|
|
||||||
{detail && !syntheticTitle && props.as.toString() === "h1" && doc.contentTitle==props.children && (
|
|
||||||
<span
|
|
||||||
style={{
|
|
||||||
display: "block",
|
|
||||||
fontSize: "14px",
|
|
||||||
fontWeight: "normal",
|
|
||||||
marginBottom: "10px",
|
|
||||||
marginTop: "10px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{dayjs(detail.create_date).format("YYYY年MM月DD日")} · 阅读需{" "}
|
|
||||||
{Math.ceil(detail.reading_time.minutes)} 分钟
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</Heading>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user