Skip to content

Commit

Permalink
add ads
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 22, 2023
1 parent 933b3e3 commit 7c84680
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 16 additions & 1 deletion src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 9 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ function HomepageHeader() {
Alist Tutorial - 2min ⏱️
</Link>
</div>
<div className={styles.buttons} style={{ marginTop: 16 }}>
<div
className="wwads wwads-cn wwads-horizontal"
data-id="219"
style={{
width: 444,
}}
></div>
</div>
</div>
</header>
);
Expand Down
122 changes: 122 additions & 0 deletions src/theme/DocItem/index.js
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Seo
{...{
title,
description,
keywords,
image,
}}
/>

<div className="row">
<div
className={clsx("col", {
[styles.docItemCol]: !hideTableOfContents,
})}
>
<DocVersionBanner versionMetadata={versionMetadata} />
<div className={styles.docItemContainer}>
<article>
{versionMetadata.badge && (
<span
className={clsx(
ThemeClassNames.docs.docVersionBadge,
"badge badge--secondary"
)}
>
Version: {versionMetadata.label}
</span>
)}

{canRenderTOC && (
<TOCCollapsible
toc={DocContent.toc}
minHeadingLevel={tocMinHeadingLevel}
maxHeadingLevel={tocMaxHeadingLevel}
className={clsx(
ThemeClassNames.docs.docTocMobile,
styles.tocMobile
)}
/>
)}

<div
className={clsx(ThemeClassNames.docs.docMarkdown, "markdown")}
>
{/*
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 && <MainHeading>{title}</MainHeading>}
<div
className="wwads wwads-cn wwads-horizontal"
data-id="219"
style={{
width: "100% !important",
}}
></div>
<DocContent />
</div>

<DocItemFooter {...props} />
</article>

<DocPaginator metadata={metadata} />
</div>
</div>
{renderTocDesktop && (
<div className="col col--3">
<TOC
toc={DocContent.toc}
minHeadingLevel={tocMinHeadingLevel}
maxHeadingLevel={tocMaxHeadingLevel}
className={ThemeClassNames.docs.docTocDesktop}
/>
</div>
)}
</div>
</>
);
}
22 changes: 22 additions & 0 deletions src/theme/DocItem/styles.module.css
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 7c84680

Please sign in to comment.