forked from jackyzha0/quartz
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔄 synced local 'quartz/' with remote 'quartz/'
- Loading branch information
Showing
55 changed files
with
1,384 additions
and
958 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" | ||
import { classNames } from "../util/lang" | ||
// @ts-ignore | ||
import script from "./scripts/comments.inline" | ||
|
||
type Options = { | ||
provider: "giscus" | ||
options: { | ||
repo: `${string}/${string}` | ||
repoId: string | ||
category: string | ||
categoryId: string | ||
mapping?: "url" | "title" | "og:title" | "specific" | "number" | "pathname" | ||
strict?: boolean | ||
reactionsEnabled?: boolean | ||
inputPosition?: "top" | "bottom" | ||
} | ||
} | ||
|
||
function boolToStringBool(b: boolean): string { | ||
return b ? "1" : "0" | ||
} | ||
|
||
export default ((opts: Options) => { | ||
const Comments: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => { | ||
return ( | ||
<div | ||
class={classNames(displayClass, "giscus")} | ||
data-repo={opts.options.repo} | ||
data-repo-id={opts.options.repoId} | ||
data-category={opts.options.category} | ||
data-category-id={opts.options.categoryId} | ||
data-mapping={opts.options.mapping ?? "url"} | ||
data-strict={boolToStringBool(opts.options.strict ?? true)} | ||
data-reactions-enabled={boolToStringBool(opts.options.reactionsEnabled ?? true)} | ||
data-input-position={opts.options.inputPosition ?? "bottom"} | ||
></div> | ||
) | ||
} | ||
|
||
Comments.afterDOMLoaded = script | ||
|
||
return Comments | ||
}) satisfies QuartzComponentConstructor<Options> |
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
Oops, something went wrong.