-
Notifications
You must be signed in to change notification settings - Fork 77
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
6 changed files
with
197 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"origins": [ | ||
"https://pester.dev", | ||
"https://pester-docs.netlify.app" | ||
], | ||
"originsRegex": [ | ||
"https://deploy-preview-[0-9]+--pester-docs.netlify.app", | ||
"http://localhost:[0-9]+" | ||
], | ||
"defaultCommentOrder": "oldest" | ||
} |
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,50 @@ | ||
import Head from '@docusaurus/Head'; | ||
import { useLocation } from '@docusaurus/router'; | ||
import { useColorMode } from '@docusaurus/theme-common'; | ||
import useBaseUrl from '@docusaurus/useBaseUrl'; | ||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
import Giscus from "@giscus/react"; | ||
import React from 'react'; | ||
|
||
/** | ||
* Adds a meta-tag to ensure new dicussion always add the canonical link in the initial post. | ||
* Avoids any localhost etc. if first reaction/post was made from a preview build | ||
* | ||
* See https://github.com/giscus/giscus/blob/main/ADVANCED-USAGE.md#giscusbacklink | ||
*/ | ||
export function GiscusHead() { | ||
const { | ||
siteConfig: { url: siteUrl }, | ||
} = useDocusaurusContext(); | ||
const { pathname } = useLocation(); | ||
const canonicalUrl = siteUrl + useBaseUrl(pathname); | ||
|
||
return ( | ||
<Head> | ||
<meta name="giscus:backlink" content={canonicalUrl} /> | ||
</Head> | ||
) | ||
} | ||
|
||
export function GiscusComponent() { | ||
const { colorMode } = useColorMode(); | ||
|
||
return ( | ||
<Giscus | ||
repo="fflaten/docs" | ||
repoId="MDEwOlJlcG9zaXRvcnkzMDY2ODYxNTc" | ||
category="Comments" | ||
categoryId="DIC_kwDOEkeozc4CWO6M" | ||
mapping="pathname" | ||
strict="1" | ||
reactionsEnabled="1" | ||
emitMetadata="0" | ||
inputPosition="top" | ||
theme={colorMode} | ||
lang="en" | ||
loading="lazy" | ||
crossorigin="anonymous" | ||
async | ||
/> | ||
); | ||
} |
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,69 @@ | ||
/** | ||
* Unsafe swizzle = might break in future minor upgrades. | ||
* Run "yarn swizzle @docusaurus/theme-classic DocItem/Layout --eject --danger" and compare the diff. | ||
* | ||
* Our customizations are marked with comments below | ||
*/ | ||
|
||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import { useWindowSize } from '@docusaurus/theme-common'; | ||
import { useDoc } from '@docusaurus/theme-common/internal'; | ||
import DocItemPaginator from '@theme/DocItem/Paginator'; | ||
import DocVersionBanner from '@theme/DocVersionBanner'; | ||
import DocVersionBadge from '@theme/DocVersionBadge'; | ||
import DocItemFooter from '@theme/DocItem/Footer'; | ||
import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile'; | ||
import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop'; | ||
import DocItemContent from '@theme/DocItem/Content'; | ||
import DocBreadcrumbs from '@theme/DocBreadcrumbs'; | ||
import styles from './styles.module.css'; | ||
/* Customization start */ | ||
import { GiscusHead, GiscusComponent } from '../../../components/Giscus'; | ||
/* Customization end */ | ||
|
||
/** | ||
* Decide if the toc should be rendered, on mobile or desktop viewports | ||
*/ | ||
function useDocTOC() { | ||
const { frontMatter, toc } = useDoc(); | ||
const windowSize = useWindowSize(); | ||
const hidden = frontMatter.hide_table_of_contents; | ||
const canRender = !hidden && toc.length > 0; | ||
const mobile = canRender ? <DocItemTOCMobile /> : undefined; | ||
const desktop = | ||
canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? ( | ||
<DocItemTOCDesktop /> | ||
) : undefined; | ||
return { | ||
hidden, | ||
mobile, | ||
desktop, | ||
}; | ||
} | ||
export default function DocItemLayout({ children }) { | ||
const docTOC = useDocTOC(); | ||
return ( | ||
<div className="row"> | ||
<div className={clsx('col', !docTOC.hidden && styles.docItemCol)}> | ||
<DocVersionBanner /> | ||
<div className={styles.docItemContainer}> | ||
<article> | ||
<DocBreadcrumbs /> | ||
<DocVersionBadge /> | ||
{docTOC.mobile} | ||
<DocItemContent>{children}</DocItemContent> | ||
<DocItemFooter /> | ||
</article> | ||
<DocItemPaginator /> | ||
</div> | ||
{/* Customization start */} | ||
<br /> | ||
<GiscusHead /> | ||
<GiscusComponent /> | ||
{/* Customization end */} | ||
</div> | ||
{docTOC.desktop && <div className="col col--3">{docTOC.desktop}</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,10 @@ | ||
.docItemContainer header + *, | ||
.docItemContainer article > *:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
@media (min-width: 997px) { | ||
.docItemCol { | ||
max-width: 75% !important; | ||
} | ||
} |
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