From 7b166602ce36fc94957c8b4990f6bd70a8c0f5e3 Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Fri, 23 Aug 2024 10:57:26 +0100 Subject: [PATCH] feat: Giscus comments based on GH discussions --- package.json | 1 + src/components/comments/index.tsx | 38 +++++++++++++++++++++ src/components/docPage/index.tsx | 14 ++++++++ yarn.lock | 56 +++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 src/components/comments/index.tsx diff --git a/package.json b/package.json index 9d9f2484f4ec2..63925c98acd00 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "@emotion/core": "^11.0.0", "@emotion/react": "^11.11.0", "@emotion/styled": "^11.0.0", + "@giscus/react": "^3.0.0", "@google-cloud/storage": "^7.7.0", "@mdx-js/loader": "^3.0.0", "@mdx-js/react": "^3.0.0", diff --git a/src/components/comments/index.tsx b/src/components/comments/index.tsx new file mode 100644 index 0000000000000..f40dc39c5eec8 --- /dev/null +++ b/src/components/comments/index.tsx @@ -0,0 +1,38 @@ +'use client'; +import Giscus, {GiscusProps} from '@giscus/react'; + +export default function GisccusComments({ + id, + repo, + repoId, + category, + categoryId, + mapping, + term, + strict, + reactionsEnabled, + emitMetadata, + inputPosition, + theme, + lang, + loading, +}: GiscusProps) { + return ( + + ); +} diff --git a/src/components/docPage/index.tsx b/src/components/docPage/index.tsx index e54ae374ff91d..41e060defe9d0 100644 --- a/src/components/docPage/index.tsx +++ b/src/components/docPage/index.tsx @@ -9,6 +9,7 @@ import './type.scss'; import {Breadcrumbs} from '../breadcrumbs'; import {CodeContextProvider} from '../codeContext'; +import GisccusComments from '../comments'; import {GitHubCTA} from '../githubCTA'; import {Header} from '../header'; import {PlatformSdkDetail} from '../platformSdkDetail'; @@ -73,6 +74,19 @@ export function DocPage({ {children} {hasGithub && } + diff --git a/yarn.lock b/yarn.lock index 4c4d762215b93..3035632c8e037 100644 --- a/yarn.lock +++ b/yarn.lock @@ -908,6 +908,13 @@ resolved "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz" integrity sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q== +"@giscus/react@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@giscus/react/-/react-3.0.0.tgz#fdadce2c7e4023eb4fdbcc219cdd97f6d7aa17f0" + integrity sha512-hgCjLpg3Wgh8VbTF5p8ZLcIHI74wvDk1VIFv12+eKhenNVUDjgwNg2B1aq/3puyHOad47u/ZSyqiMtohjy/OOA== + dependencies: + giscus "^1.5.0" + "@google-cloud/paginator@^5.0.0": version "5.0.0" resolved "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-5.0.0.tgz" @@ -1341,6 +1348,18 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" +"@lit-labs/ssr-dom-shim@^1.2.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz#2f3a8f1d688935c704dbc89132394a41029acbb8" + integrity sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ== + +"@lit/reactive-element@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@lit/reactive-element/-/reactive-element-2.0.4.tgz#8f2ed950a848016383894a26180ff06c56ae001b" + integrity sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ== + dependencies: + "@lit-labs/ssr-dom-shim" "^1.2.0" + "@mark.probst/unicode-properties@~1.1.0": version "1.1.0" resolved "https://registry.npmjs.org/@mark.probst/unicode-properties/-/unicode-properties-1.1.0.tgz" @@ -3290,6 +3309,11 @@ resolved "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz" integrity sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA== +"@types/trusted-types@^2.0.2": + version "2.0.7" + resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.7.tgz#baccb07a970b91707df3a3e8ba6896c57ead2d11" + integrity sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw== + "@types/unist@*", "@types/unist@^3.0.0": version "3.0.2" resolved "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz" @@ -5875,6 +5899,13 @@ get-tsconfig@^4.5.0: dependencies: resolve-pkg-maps "^1.0.0" +giscus@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/giscus/-/giscus-1.5.0.tgz#8299fa056b2ed31ec8b05d4645871e016982b4b2" + integrity sha512-t3LL0qbSO3JXq3uyQeKpF5CegstGfKX/0gI6eDe1cmnI7D56R7j52yLdzw4pdKrg3VnufwCgCM3FDz7G1Qr6lg== + dependencies: + lit "^3.1.2" + github-slugger@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz" @@ -7605,6 +7636,31 @@ lines-and-columns@^1.1.6: resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== +lit-element@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-4.1.0.tgz#cea3eb25f15091e3fade07c4d917fa6aaf56ba7d" + integrity sha512-gSejRUQJuMQjV2Z59KAS/D4iElUhwKpIyJvZ9w+DIagIQjfJnhR20h2Q5ddpzXGS+fF0tMZ/xEYGMnKmaI/iww== + dependencies: + "@lit-labs/ssr-dom-shim" "^1.2.0" + "@lit/reactive-element" "^2.0.4" + lit-html "^3.2.0" + +lit-html@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-3.2.0.tgz#cb09071a8a1f5f0850873f9143f18f0260be1fda" + integrity sha512-pwT/HwoxqI9FggTrYVarkBKFN9MlTUpLrDHubTmW4SrkL3kkqW5gxwbxMMUnbbRHBC0WTZnYHcjDSCM559VyfA== + dependencies: + "@types/trusted-types" "^2.0.2" + +lit@^3.1.2: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lit/-/lit-3.2.0.tgz#2189d72bccbc335f733a67bfbbd295f015e68e05" + integrity sha512-s6tI33Lf6VpDu7u4YqsSX78D28bYQulM+VAzsGch4fx2H0eLZnJsUBsPWmGYSGoKDNbjtRv02rio1o+UdPVwvw== + dependencies: + "@lit/reactive-element" "^2.0.4" + lit-element "^4.1.0" + lit-html "^3.2.0" + locate-path@^5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz"