@@ -4,57 +4,59 @@ import { classNames } from "../util/lang"
44import script from "./scripts/comments.inline"
55
66type Options = {
7- provider : "giscus"
8- options : {
9- repo : `${string } /${string } `
10- repoId : string
11- category : string
12- categoryId : string
13- themeUrl ?: string
14- lightTheme ?: string
15- darkTheme ?: string
16- mapping ?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
17- strict ?: boolean
18- reactionsEnabled ?: boolean
19- inputPosition ?: "top" | "bottom"
20- }
7+ provider : "giscus"
8+ options : {
9+ repo : `${string } /${string } `
10+ repoId : string
11+ category : string
12+ categoryId : string
13+ themeUrl ?: string
14+ lightTheme ?: string
15+ darkTheme ?: string
16+ mapping ?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
17+ strict ?: boolean
18+ reactionsEnabled ?: boolean
19+ loading ?: "lazy" | ""
20+ inputPosition ?: "top" | "bottom"
21+ }
2122}
2223
2324function boolToStringBool ( b : boolean ) : string {
24- return b ? "1" : "0"
25+ return b ? "1" : "0"
2526}
2627
2728export default ( ( opts : Options ) => {
28- const Comments : QuartzComponent = ( { displayClass, fileData, cfg } : QuartzComponentProps ) => {
29- // check if comments should be displayed according to frontmatter
30- const disableComment : boolean =
31- typeof fileData . frontmatter ?. comments !== "undefined" &&
32- ( ! fileData . frontmatter ?. comments || fileData . frontmatter ?. comments === "false" )
33- if ( disableComment ) {
34- return < > </ >
35- }
36-
37- return (
38- < div
39- class = { classNames ( displayClass , "giscus" ) }
40- data-repo = { opts . options . repo }
41- data-repo-id = { opts . options . repoId }
42- data-category = { opts . options . category }
43- data-category-id = { opts . options . categoryId }
44- data-mapping = { opts . options . mapping ?? "url" }
45- data-strict = { boolToStringBool ( opts . options . strict ?? true ) }
46- data-reactions-enabled = { boolToStringBool ( opts . options . reactionsEnabled ?? true ) }
47- data-input-position = { opts . options . inputPosition ?? "bottom" }
48- data-light-theme = { opts . options . lightTheme ?? "light" }
49- data-dark-theme = { opts . options . darkTheme ?? "dark" }
50- data-theme-url = {
51- opts . options . themeUrl ?? `https://${ cfg . baseUrl ?? "example.com" } /static/giscus`
29+ const Comments : QuartzComponent = ( { displayClass, fileData, cfg } : QuartzComponentProps ) => {
30+ // check if comments should be displayed according to frontmatter
31+ const disableComment : boolean =
32+ typeof fileData . frontmatter ?. comments !== "undefined" &&
33+ ( ! fileData . frontmatter ?. comments || fileData . frontmatter ?. comments === "false" )
34+ if ( disableComment ) {
35+ return < > </ >
5236 }
53- > </ div >
54- )
55- }
5637
57- Comments . afterDOMLoaded = script
38+ return (
39+ < div
40+ class = { classNames ( displayClass , "giscus" ) }
41+ data-repo = { opts . options . repo }
42+ data-repo-id = { opts . options . repoId }
43+ data-category = { opts . options . category }
44+ data-category-id = { opts . options . categoryId }
45+ data-mapping = { opts . options . mapping ?? "url" }
46+ data-strict = { boolToStringBool ( opts . options . strict ?? true ) }
47+ data-reactions-enabled = { boolToStringBool ( opts . options . reactionsEnabled ?? true ) }
48+ data-input-position = { opts . options . inputPosition ?? "bottom" }
49+ data-light-theme = { opts . options . lightTheme ?? "light" }
50+ data-dark-theme = { opts . options . darkTheme ?? "dark" }
51+ data-loading = { opts . options . loading ?? "" }
52+ data-theme-url = {
53+ opts . options . themeUrl ?? `https://${ cfg . baseUrl ?? "example.com" } /static/giscus`
54+ }
55+ > </ div >
56+ )
57+ }
58+
59+ Comments . afterDOMLoaded = script
5860
59- return Comments
61+ return Comments
6062} ) satisfies QuartzComponentConstructor < Options >
0 commit comments