added remark42
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Struchkov Mark 2024-09-03 08:50:23 +03:00
parent becfc27348
commit 11cd9295b2
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,55 @@
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import { classNames } from "../util/lang"
// @ts-ignore
// import script from "./scripts/comments.inline"
type Options = {
options: {
host: string
siteId: string
locale: string
}
}
// function boolToStringBool(b: boolean): string {
// return b ? "1" : "0"
// }
export default ((opts: Options) => {
const Remark: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
const remarkConfig = `
var remark_config = {
host: "${opts.options.host}",
site_id: "${opts.options.siteId}",
components: ["embed"],
locale: "${opts.options.locale}",
theme: localStorage.theme,
show_email_subscription: false,
simple_view: false
};
`;
const embedScript = `
!function(e,n){
for(var o=0;o<e.length;o++){
var r=n.createElement("script"),
c=".js",
d=n.head||n.body;
"noModule" in r ? (r.type="module",c=".mjs") : r.async=!0,
r.defer=!0,
r.src=remark_config.host+"/web/"+e[o]+c,
d.appendChild(r)
}
}(remark_config.components||["embed"], document);
`;
return (
<>
<script dangerouslySetInnerHTML={{ __html: remarkConfig }}></script>
<script dangerouslySetInnerHTML={{ __html: embedScript }}></script>
</>
);
};
return Remark;
}) satisfies QuartzComponentConstructor<Options>;

View File

@ -20,6 +20,7 @@ import MobileOnly from "./MobileOnly"
import RecentNotes from "./RecentNotes"
import Breadcrumbs from "./Breadcrumbs"
import Comments from "./Comments"
import Remark from "./Remark"
export {
ArticleTitle,
@ -44,4 +45,5 @@ export {
NotFound,
Breadcrumbs,
Comments,
Remark
}