-
Notifications
You must be signed in to change notification settings - Fork 889
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
13 changed files
with
3,043 additions
and
3,113 deletions.
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
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 |
---|---|---|
|
@@ -43,5 +43,8 @@ | |
"leaflet": "^1.7.1", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1" | ||
}, | ||
"jest": { | ||
"testEnvironment": "jsdom" | ||
} | ||
} |
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
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,131 @@ | ||
/** | ||
* 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 {useActivePlugin, useVersions} from '@theme/hooks/useDocs'; | ||
import useWindowSize from '@theme/hooks/useWindowSize'; | ||
import DocPaginator from '@theme/DocPaginator'; | ||
import DocVersionBanner from '@theme/DocVersionBanner'; | ||
import Seo from '@theme/Seo'; | ||
import LastUpdated from '@theme/LastUpdated'; | ||
import TOC from '@theme/TOC'; | ||
import TOCCollapsible from '@theme/TOCCollapsible'; | ||
import EditThisPage from '@theme/EditThisPage'; | ||
import {MainHeading} from '@theme/Heading'; | ||
import styles from './styles.module.css'; | ||
|
||
function DocItem(props) { | ||
const {content: DocContent, versionMetadata} = props; | ||
const {metadata, frontMatter} = DocContent; | ||
const { | ||
image, | ||
keywords, | ||
hide_title: hideTitle, | ||
hide_table_of_contents: hideTableOfContents, | ||
} = frontMatter; | ||
const { | ||
description, | ||
title, | ||
editUrl, | ||
lastUpdatedAt, | ||
formattedLastUpdatedAt, | ||
lastUpdatedBy, | ||
} = metadata; | ||
const {pluginId} = useActivePlugin({ | ||
failfast: true, | ||
}); | ||
const versions = useVersions(pluginId); // If site is not versioned or only one version is included | ||
// we don't show the version badge | ||
// See https://github.com/facebook/docusaurus/issues/3362 | ||
|
||
const showVersionBadge = versions.length > 1; // 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> | ||
{showVersionBadge && ( | ||
<span className="badge badge--secondary"> | ||
Version: {versionMetadata.label} | ||
</span> | ||
)} | ||
|
||
{canRenderTOC && ( | ||
<TOCCollapsible | ||
toc={DocContent.toc} | ||
className={styles.tocMobile} | ||
/> | ||
)} | ||
|
||
<div className="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>} | ||
|
||
<DocContent /> | ||
</div> | ||
|
||
{(editUrl || lastUpdatedAt || lastUpdatedBy) && ( | ||
<footer className="row docusaurus-mt-lg"> | ||
<div className="col"> | ||
{editUrl && <EditThisPage editUrl={editUrl} />} | ||
</div> | ||
|
||
<div className={clsx('col', styles.lastUpdated)}> | ||
{(lastUpdatedAt || lastUpdatedBy) && ( | ||
<LastUpdated | ||
lastUpdatedAt={lastUpdatedAt} | ||
formattedLastUpdatedAt={formattedLastUpdatedAt} | ||
lastUpdatedBy={lastUpdatedBy} | ||
/> | ||
)} | ||
</div> | ||
</footer> | ||
)} | ||
</article> | ||
|
||
<DocPaginator metadata={metadata} /> | ||
</div> | ||
</div> | ||
{renderTocDesktop && ( | ||
<div className="col col--3"> | ||
<TOC toc={DocContent.toc} /> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default DocItem; |
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,32 @@ | ||
/** | ||
* 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; | ||
} | ||
|
||
.lastUpdated { | ||
margin-top: 0.2rem; | ||
font-style: italic; | ||
font-size: smaller; | ||
} | ||
|
||
@media only screen and (min-width: 997px) { | ||
.docItemCol { | ||
max-width: 75% !important; | ||
} | ||
|
||
.lastUpdated { | ||
text-align: right; | ||
} | ||
|
||
/* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */ | ||
.tocMobile { | ||
display: none; | ||
} | ||
} |
Oops, something went wrong.