Merge pull request #1372 from rcarteraz/add-blog-comments

Add Comments To Blog
This commit is contained in:
Ben Meadors 2024-08-14 15:25:56 -05:00 committed by GitHub
commit cfa895ca16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 189 additions and 1 deletions

View file

@ -19,6 +19,7 @@
"@docusaurus/preset-classic": "3.1.1",
"@docusaurus/theme-common": "3.1.1",
"@docusaurus/theme-mermaid": "3.1.1",
"@giscus/react": "^3.0.0",
"@heroicons/react": "^2.1.1",
"@mdx-js/react": "^3.0.1",
"@meshtastic/js": "2.2.23-0",

View file

@ -23,6 +23,9 @@ dependencies:
'@docusaurus/theme-mermaid':
specifier: 3.1.1
version: 3.1.1(react-dom@18.2.0)(react@18.2.0)(typescript@5.3.3)
'@giscus/react':
specifier: ^3.0.0
version: 3.0.0(react-dom@18.2.0)(react@18.2.0)
'@heroicons/react':
specifier: ^2.1.1
version: 2.1.1(react@18.2.0)
@ -1655,7 +1658,7 @@ packages:
dev: false
/@buf/meshtastic_protobufs.bufbuild_es@1.7.2-20240216123215-6b07c41c68c9.1(@bufbuild/protobuf@1.7.2):
resolution: {tarball: https://buf.build/gen/npm/v1/@buf/meshtastic_protobufs.bufbuild_es/-/meshtastic_protobufs.bufbuild_es-1.7.2-20240216123215-6b07c41c68c9.1.tgz}
resolution: {registry: https://buf.build/gen/npm/v1, tarball: https://buf.build/gen/npm/v1/@buf/meshtastic_protobufs.bufbuild_es/-/meshtastic_protobufs.bufbuild_es-1.7.2-20240216123215-6b07c41c68c9.1.tgz}
peerDependencies:
'@bufbuild/protobuf': ^1.7.2
dependencies:
@ -2519,6 +2522,17 @@ packages:
- webpack-cli
dev: false
/@giscus/react@3.0.0(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-hgCjLpg3Wgh8VbTF5p8ZLcIHI74wvDk1VIFv12+eKhenNVUDjgwNg2B1aq/3puyHOad47u/ZSyqiMtohjy/OOA==}
peerDependencies:
react: ^16 || ^17 || ^18
react-dom: ^16 || ^17 || ^18
dependencies:
giscus: 1.5.0
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: false
/@hapi/hoek@9.3.0:
resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==}
@ -2600,6 +2614,16 @@ packages:
resolution: {integrity: sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==}
dev: false
/@lit-labs/ssr-dom-shim@1.2.1:
resolution: {integrity: sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==}
dev: false
/@lit/reactive-element@2.0.4:
resolution: {integrity: sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==}
dependencies:
'@lit-labs/ssr-dom-shim': 1.2.1
dev: false
/@mdx-js/mdx@3.0.1:
resolution: {integrity: sha512-eIQ4QTrOWyL3LWEe/bu6Taqzq2HQvHcyTMaOrI95P2/LmJE7AsfPfgJGuFLPVqBUE1BC1rik3VIhU+s9u72arA==}
dependencies:
@ -3193,6 +3217,10 @@ packages:
'@types/node': 20.11.19
dev: false
/@types/trusted-types@2.0.7:
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
dev: false
/@types/unist@2.0.10:
resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==}
@ -5534,6 +5562,12 @@ packages:
resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}
engines: {node: '>=10'}
/giscus@1.5.0:
resolution: {integrity: sha512-t3LL0qbSO3JXq3uyQeKpF5CegstGfKX/0gI6eDe1cmnI7D56R7j52yLdzw4pdKrg3VnufwCgCM3FDz7G1Qr6lg==}
dependencies:
lit: 3.2.0
dev: false
/github-slugger@1.5.0:
resolution: {integrity: sha512-wIh+gKBI9Nshz2o46B0B3f5k/W+WI9ZAv6y5Dn5WJ5SK1t0TnDimB4WE5rmTD05ZAIn8HALCZVmCsvj0w0v0lw==}
dev: false
@ -6563,6 +6597,28 @@ packages:
/lines-and-columns@1.2.4:
resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==}
/lit-element@4.1.0:
resolution: {integrity: sha512-gSejRUQJuMQjV2Z59KAS/D4iElUhwKpIyJvZ9w+DIagIQjfJnhR20h2Q5ddpzXGS+fF0tMZ/xEYGMnKmaI/iww==}
dependencies:
'@lit-labs/ssr-dom-shim': 1.2.1
'@lit/reactive-element': 2.0.4
lit-html: 3.2.0
dev: false
/lit-html@3.2.0:
resolution: {integrity: sha512-pwT/HwoxqI9FggTrYVarkBKFN9MlTUpLrDHubTmW4SrkL3kkqW5gxwbxMMUnbbRHBC0WTZnYHcjDSCM559VyfA==}
dependencies:
'@types/trusted-types': 2.0.7
dev: false
/lit@3.2.0:
resolution: {integrity: sha512-s6tI33Lf6VpDu7u4YqsSX78D28bYQulM+VAzsGch4fx2H0eLZnJsUBsPWmGYSGoKDNbjtRv02rio1o+UdPVwvw==}
dependencies:
'@lit/reactive-element': 2.0.4
lit-element: 4.1.0
lit-html: 3.2.0
dev: false
/loader-runner@4.3.0:
resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==}
engines: {node: '>=6.11.5'}

View file

@ -0,0 +1,27 @@
import { useColorMode } from "@docusaurus/theme-common";
import Giscus from "@giscus/react";
import React from "react";
export default function GiscusComponent() {
const { colorMode } = useColorMode();
return (
<Giscus
repo="meshtastic/meshtastic"
repoId="MDEwOlJlcG9zaXRvcnkzMzkzMDEyMjI="
category="Blog Post Comments"
categoryId="DIC_kwDOFDlTZs4Choq7"
mapping="pathname"
term="specific-term" //If you didn't select "Discussion title contains a specific term", omit.
strict="1"
reactionsEnabled="1"
emitMetadata="0"
inputPosition="top"
theme={colorMode}
lang="en"
loading="lazy"
crossorigin="anonymous"
async
/>
);
}

View file

@ -0,0 +1,37 @@
import { PageMetadata } from "@docusaurus/theme-common";
import { useBlogPost } from "@docusaurus/theme-common/internal";
import React from "react";
export default function BlogPostPageMetadata() {
const { assets, metadata } = useBlogPost();
const { title, description, date, tags, authors, frontMatter } = metadata;
const { keywords } = frontMatter;
const image = assets.image ?? frontMatter.image;
return (
<PageMetadata
title={title}
description={description}
keywords={keywords}
image={image}
>
<meta property="og:type" content="article" />
<meta property="article:published_time" content={date} />
{/* TODO double check those article meta array syntaxes, see https://ogp.me/#array */}
{authors.some((author) => author.url) && (
<meta
property="article:author"
content={authors
.map((author) => author.url)
.filter(Boolean)
.join(",")}
/>
)}
{tags.length > 0 && (
<meta
property="article:tag"
content={tags.map((tag) => tag.label).join(",")}
/>
)}
</PageMetadata>
);
}

View file

@ -0,0 +1,67 @@
import {
HtmlClassNameProvider,
ThemeClassNames,
} from "@docusaurus/theme-common";
import {
BlogPostProvider,
useBlogPost,
} from "@docusaurus/theme-common/internal";
import GiscusComponent from "@site/src/components/GiscusComponent";
import BlogLayout from "@theme/BlogLayout";
import BlogPostItem from "@theme/BlogPostItem";
import BlogPostPageMetadata from "@theme/BlogPostPage/Metadata";
import BlogPostPaginator from "@theme/BlogPostPaginator";
import TOC from "@theme/TOC";
import Unlisted from "@theme/Unlisted";
import clsx from "clsx";
import React from "react";
function BlogPostPageContent({ sidebar, children }) {
const { metadata, toc } = useBlogPost();
const { nextItem, prevItem, frontMatter, unlisted } = metadata;
const {
hide_table_of_contents: hideTableOfContents,
toc_min_heading_level: tocMinHeadingLevel,
toc_max_heading_level: tocMaxHeadingLevel,
} = frontMatter;
return (
<BlogLayout
sidebar={sidebar}
toc={
!hideTableOfContents && toc.length > 0 ? (
<TOC
toc={toc}
minHeadingLevel={tocMinHeadingLevel}
maxHeadingLevel={tocMaxHeadingLevel}
/>
) : undefined
}
>
{unlisted && <Unlisted />}
<BlogPostItem>{children}</BlogPostItem>
<GiscusComponent />
{(nextItem || prevItem) && (
<BlogPostPaginator nextItem={nextItem} prevItem={prevItem} />
)}
</BlogLayout>
);
}
export default function BlogPostPage(props) {
const BlogPostContent = props.content;
return (
<BlogPostProvider content={props.content} isBlogPostPage>
<HtmlClassNameProvider
className={clsx(
ThemeClassNames.wrapper.blogPages,
ThemeClassNames.page.blogPostPage,
)}
>
<BlogPostPageMetadata />
<BlogPostPageContent sidebar={props.sidebar}>
<BlogPostContent />
</BlogPostPageContent>
</HtmlClassNameProvider>
</BlogPostProvider>
);
}