@@ -4,59 +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- loading ?: "lazy " | ""
20- inputPosition ?: "top" | "bottom"
21- }
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+ lang ?: string
21+ }
2222}
2323
2424function boolToStringBool ( b : boolean ) : string {
25- return b ? "1" : "0"
25+ return b ? "1" : "0"
2626}
2727
2828export default ( ( opts : Options ) => {
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 < > </ >
36- }
37-
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- )
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 < > </ >
5736 }
5837
59- 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-theme-url = {
52+ opts . options . themeUrl ?? `https://${ cfg . baseUrl ?? "example.com" } /static/giscus`
53+ }
54+ data-lang = { opts . options . lang ?? "en" }
55+ > </ div >
56+ )
57+ }
58+
59+ Comments . afterDOMLoaded = script
6060
61- return Comments
61+ return Comments
6262} ) satisfies QuartzComponentConstructor < Options >
0 commit comments