-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |