From 7eb4e3f4e746f04c0591e1ba5e99ac00098e9d37 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 20 May 2024 09:41:17 -0700 Subject: [PATCH] Enable comments --- package.json | 3 +++ src/giscus.json.template.js | 26 ++++++++++++++++++++++ src/layouts/article.layout.client.js | 1 + src/layouts/article.layout.js | 28 +++++++++++++++++++----- src/layouts/book-review.layout.client.js | 1 + 5 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/giscus.json.template.js create mode 100644 src/layouts/article.layout.client.js create mode 100644 src/layouts/book-review.layout.client.js diff --git a/package.json b/package.json index 27403a6..290c00c 100644 --- a/package.json +++ b/package.json @@ -59,5 +59,8 @@ "engines": { "node": ">=16.0.0", "npm": ">=8.3.1" + }, + "dependencies": { + "giscus": "^1.5.0" } } diff --git a/src/giscus.json.template.js b/src/giscus.json.template.js new file mode 100644 index 0000000..c2b3b15 --- /dev/null +++ b/src/giscus.json.template.js @@ -0,0 +1,26 @@ +/** + * @template T + * @typedef {import('top-bun').TemplateFunction} TemplateFunction + */ + +/** @type {TemplateFunction<{ + * siteName: string, + * description: string, + * siteUrl: string, + * authorName: string, + * authorUrl: string, + * authorImgUrl: string + * layout: string, + * publishDate: string + * title: string + * }>} */ +export default async ({ + vars: { + siteUrl + } +}) => { + return JSON.stringify({ + origins: [siteUrl], + originsRegex: ['http://localhost:[0-9]+'] + }, null, ' ') +} diff --git a/src/layouts/article.layout.client.js b/src/layouts/article.layout.client.js new file mode 100644 index 0000000..8507920 --- /dev/null +++ b/src/layouts/article.layout.client.js @@ -0,0 +1 @@ +import 'giscus' diff --git a/src/layouts/article.layout.js b/src/layouts/article.layout.js index ea95364..11f504e 100644 --- a/src/layouts/article.layout.js +++ b/src/layouts/article.layout.js @@ -51,12 +51,30 @@ export default function articleLayout (args) { } - + + + +
+ ${breadcrumb({ pathSegments })} ` diff --git a/src/layouts/book-review.layout.client.js b/src/layouts/book-review.layout.client.js new file mode 100644 index 0000000..a01899c --- /dev/null +++ b/src/layouts/book-review.layout.client.js @@ -0,0 +1 @@ +import './article.layout.client.js'