Skip to content

Commit

Permalink
chore: update gpts
Browse files Browse the repository at this point in the history
  • Loading branch information
lencx committed Nov 13, 2023
1 parent c0d7195 commit 8a86ba6
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ dist-ssr
*.sw?

yarn.lock
dev-dist
2 changes: 1 addition & 1 deletion gpthub.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="description" content="Discover the Best in Custom GPT at OpenAI's GPT Store – Your Adventure Begins Here!" />
<meta name="keywords" content="ChatGPT, OpenAI, GPTs, AI, Store, Tools">
<meta name="google-adsense-account" content="ca-pub-5066880741262012">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KP12ZRYGBJ"></script>
<script>
window.dataLayer = window.dataLayer || [];
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"preview": "vite preview"
},
"dependencies": {
"@giscus/react": "^2.3.0",
"clsx": "^2.0.0",
"dayjs": "^1.11.10",
"lodash": "^4.17.21",
Expand Down
46 changes: 46 additions & 0 deletions src/components/Comments.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { useEffect, useState } from 'react';
import Giscus from '@giscus/react';

export default function Comments() {
const [isDark, setDark] = useState(false);

useEffect(() => {
setDark(localStorage.getItem('theme') === 'dracula');
}, [])

useEffect(() => {
const targetNode = document.documentElement;
const observer = new MutationObserver((mutationsList) => {
for (const mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
console.log('data-theme attribute changed:', targetNode.getAttribute('data-theme'));
setDark(!isDark);
}
}
});

const config = { attributes: true, attributeFilter: ['data-theme'] };
observer.observe(targetNode, config);
return () => {
observer.disconnect();
};
}, [isDark]);

return (
<Giscus
id="comments"
repo="lencx/gpthub"
repoId="R_kgDOKrn4Tw"
category="Comments"
categoryId="DIC_kwDOF1L2fM4B-hVS"
mapping="pathname"
term="Welcome to GPTHub!"
reactionsEnabled="1"
emitMetadata="0"
inputPosition="top"
theme={isDark ? 'dark_dimmed' : 'light_tritanopia'}
lang="en"
loading="lazy"
/>
);
}
7 changes: 6 additions & 1 deletion src/views/GPTDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useMemo } from 'react';
import { useParams } from 'react-router-dom';
import dayjs from 'dayjs';
import Giscus from '@giscus/react';

Check failure on line 4 in src/views/GPTDetail.tsx

View workflow job for this annotation

GitHub Actions / deploy

'Giscus' is declared but its value is never read.

import { gptLink } from '@/utils';
import GPTTools from '@components/GPTTools';
import GPTPrompts from '@components/GPTPrompts';
import GPTHubNote from '@components/GPTHubNote';
import Comments from '@components/Comments'
import data from '@@/gpthub.json';

export default function GPTs() {
Expand Down Expand Up @@ -49,6 +51,9 @@ export default function GPTs() {
rel="noopener noreferrer"
/>
</div>
<div className="mt-10">
<Comments />
</div>
</div>
);
}
}
7 changes: 6 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export default defineConfig({
tsconfigPaths(),
react(),
splitVendorChunkPlugin(),
VitePWA(),
VitePWA({
registerType: 'autoUpdate',
// devOptions: {
// enabled: true,
// },
}),
],
})

0 comments on commit 8a86ba6

Please sign in to comment.