From 000fbb7afeb3f32ffc9c564414dcf285df683041 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Wed, 22 Feb 2023 15:59:11 +0800 Subject: [PATCH] add ads --- docusaurus.config.js | 9 ++ src/css/custom.css | 17 +++- src/pages/index.js | 9 ++ src/theme/DocItem/index.js | 122 ++++++++++++++++++++++++++++ src/theme/DocItem/styles.module.css | 22 +++++ 5 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 src/theme/DocItem/index.js create mode 100644 src/theme/DocItem/styles.module.css diff --git a/docusaurus.config.js b/docusaurus.config.js index 9025378..3fabbfa 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -8,6 +8,15 @@ const darkCodeTheme = require("prism-react-renderer/themes/dracula"); const config = { title: "Alist Document", scripts: [ + { + src: "https://cdn.wwads.cn/js/makemoney.js", + type: "text/javascript", + charset: "UTF-8", + }, + { + src: "https://alist.nn.ci/adb.js", + async: true, + }, { src: "https://hm.baidu.com/hm.js?0d5809a3ff8af1329f415ca8088cc2a0", async: true, diff --git a/src/css/custom.css b/src/css/custom.css index 6abe148..cd64c1b 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -23,6 +23,21 @@ padding: 0 var(--ifm-pre-padding); } -html[data-theme='dark'] .docusaurus-highlight-code-line { +html[data-theme="dark"] .docusaurus-highlight-code-line { background-color: rgba(0, 0, 0, 0.3); } + +.wwads-cn, +.wwads { + background-color: #f4f8fa; +} +.wwads-text { + color: #0e1011; +} +html[data-theme="dark"] .wwads-cn, +html[data-theme="dark"] .wwads { + background-color: #272829 !important; +} +html[data-theme="dark"] .wwads-text { + color: #9e9e9e !important; +} diff --git a/src/pages/index.js b/src/pages/index.js index 230cb01..de37294 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -40,6 +40,15 @@ export default function Home() { >
+
+
+
diff --git a/src/theme/DocItem/index.js b/src/theme/DocItem/index.js new file mode 100644 index 0000000..cc4dc87 --- /dev/null +++ b/src/theme/DocItem/index.js @@ -0,0 +1,122 @@ +/** + * 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 useWindowSize from "@theme/hooks/useWindowSize"; +import DocPaginator from "@theme/DocPaginator"; +import DocVersionBanner from "@theme/DocVersionBanner"; +import Seo from "@theme/Seo"; +import DocItemFooter from "@theme/DocItemFooter"; +import TOC from "@theme/TOC"; +import TOCCollapsible from "@theme/TOCCollapsible"; +import { MainHeading } from "@theme/Heading"; +import styles from "./styles.module.css"; +import { ThemeClassNames } from "@docusaurus/theme-common"; +export default function DocItem(props) { + const { content: DocContent, versionMetadata } = props; + const { metadata, frontMatter } = DocContent; + const { + image, + keywords, + hide_title: hideTitle, + hide_table_of_contents: hideTableOfContents, + toc_min_heading_level: tocMinHeadingLevel, + toc_max_heading_level: tocMaxHeadingLevel, + } = frontMatter; + const { description, title } = metadata; // We only add a title if: + // - user asks to hide it with frontmatter + // - the markdown content does not already contain a top-level h1 heading + + const shouldAddTitle = + !hideTitle && typeof DocContent.contentTitle === "undefined"; + const windowSize = useWindowSize(); + const canRenderTOC = + !hideTableOfContents && DocContent.toc && DocContent.toc.length > 0; + const renderTocDesktop = + canRenderTOC && (windowSize === "desktop" || windowSize === "ssr"); + return ( + <> + + +
+
+ +
+
+ {versionMetadata.badge && ( + + Version: {versionMetadata.label} + + )} + + {canRenderTOC && ( + + )} + +
+ {/* + Title can be declared inside md content or declared through frontmatter 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 + */} + {shouldAddTitle && {title}} +
+ +
+ + +
+ + +
+
+ {renderTocDesktop && ( +
+ +
+ )} +
+ + ); +} diff --git a/src/theme/DocItem/styles.module.css b/src/theme/DocItem/styles.module.css new file mode 100644 index 0000000..dbfe5bc --- /dev/null +++ b/src/theme/DocItem/styles.module.css @@ -0,0 +1,22 @@ +/** + * 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. + */ + +.docItemContainer article > *:first-child, +.docItemContainer header + * { + margin-top: 0; +} + +@media (min-width: 997px) { + .docItemCol { + max-width: 75% !important; + } + + /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */ + .tocMobile { + display: none; + } +}