-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
7 changed files
with
249 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
### Disabled this feature | ||
|
||
- `discussion: null` or simply remove this properties | ||
|
||
### Enable this feature | ||
|
||
|
||
|
||
Please visit [here](https://giscus.app/) and follow the instructions, include enable giscus app, allow permission for giscus to access your repository. | ||
|
||
Get configuration that are generated and fill the quartz configuration . | ||
|
||
```typescript title="quartz.config.ts" | ||
const config: QuartzConfig = { | ||
configuration: { | ||
..., | ||
discussion: { | ||
provider: "giscus", | ||
configuration: { | ||
dataRepo: "<data-repo>", | ||
dataRepoId: "<data-repo-id>", | ||
dataCategory: "<data-category>", | ||
dataCategoryId: "<data-category-id>", | ||
}, | ||
}, | ||
|
||
... | ||
} | ||
|
||
``` | ||
> [!note] | ||
> By default, four fields `data-repo/id` and `data-category/id` must be fill by yourself. And there are 10 other fields | ||
> have default settings. You can overwrite them. | ||
| Name | Default value | | ||
|------------------------|--------------------------------| | ||
| src | "https://giscus.app/client.js" | | ||
| data-strict | "0" | | ||
| data-mapping | "pathname" | | ||
| data-reactions-enabled | "1" | | ||
| data-emit-metadata | "1" | | ||
| data-input-position | "top" | | ||
| data-theme | "preferred_color_scheme" | | ||
| data-lang | "en" | | ||
| data-loading | "lazy" | | ||
| data-origin | "anonymous" | | ||
Finally, add discussion/comment session to your `quartz.layout.ts` | ||
```typescript title="quartz.layout.ts" | ||
export const defaultContentPageLayout: PageLayout = { | ||
beforeBody: [ | ||
... | ||
], | ||
left: [ | ||
... | ||
], | ||
right: [ | ||
... | ||
], | ||
//@ts-ignore | ||
footer: Component.Discussion(), | ||
} | ||
|
||
|
||
``` |
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,49 @@ | ||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" | ||
|
||
const Discussion: QuartzComponent = ({ cfg }: QuartzComponentProps) => { | ||
|
||
const discussion = cfg.discussion | ||
|
||
const configuration = discussion?.configuration | ||
const src = configuration?.src ? configuration.src : "https://giscus.app/client.js" | ||
const dataStrict = configuration?.dataStrict ? configuration.dataStrict : "0" | ||
const dataMapping = configuration?.dataMapping ? configuration.dataMapping : "pathname" | ||
const dataReactionsEnabled = configuration?.dataReactionsEnabled ? configuration.dataReactionsEnabled : "1" | ||
const dataEmitMetadata = configuration?.dataEmitMetadata ? configuration.dataEmitMetadata : "1" | ||
const dataInputPosition = configuration?.dataInputPosition ? configuration.dataInputPosition : "top" | ||
const dataTheme = configuration?.dataTheme ? configuration.dataTheme : "preferred_color_scheme" | ||
const dataLang = configuration?.dataLang ? configuration.dataLang : "en" | ||
const dataLoading = configuration?.dataLoading ? configuration.dataLoading : "lazy" | ||
const crossOrigin = configuration?.crossorigin ? configuration.crossorigin : "anonymous" | ||
|
||
if (discussion?.provider === "giscus" | ||
) { | ||
return <> | ||
<script src={src} | ||
data-repo={discussion.configuration.dataRepo} | ||
data-repo-id={discussion.configuration.dataRepoId} | ||
data-category={discussion.configuration.dataCategory} | ||
data-category-id={discussion.configuration.dataCategoryId} | ||
data-mapping={dataMapping} | ||
data-strict={dataStrict} | ||
data-reactions-enabled={dataReactionsEnabled} | ||
data-emit-metadata={dataEmitMetadata} | ||
data-input-position={dataInputPosition} | ||
data-theme={dataTheme} | ||
data-lang={dataLang} | ||
data-loading={dataLoading} | ||
crossorigin={crossOrigin} | ||
async> | ||
</script> | ||
<div id="disqus_thread"></div> | ||
</> | ||
|
||
} else { | ||
return null | ||
} | ||
|
||
} | ||
|
||
export default (() => Discussion) satisfies QuartzComponentConstructor | ||
|
||
|
Oops, something went wrong.