Skip to content

Commit

Permalink
Add 2022 posts
Browse files Browse the repository at this point in the history
  • Loading branch information
emeraldjava committed Nov 10, 2024
1 parent aad1e6b commit 8bbe7fb
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 6 deletions.
82 changes: 76 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"@astrojs/check": "^0.9.3",
"@astrojs/rss": "^4.0.7",
"@giscus/react": "^3.0.0",
"@resvg/resvg-js": "^2.6.2",
"astro": "^4.16.3",
"fuse.js": "^7.0.0",
Expand Down
51 changes: 51 additions & 0 deletions src/components/Comments.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Giscus, { type Theme } from "@giscus/react";
import { GISCUS } from "@config";
import { useEffect, useState } from "react";

interface CommentsProps {
lightTheme?: Theme;
darkTheme?: Theme;
}

export default function Comments({
lightTheme = "light",
darkTheme = "dark",
}: CommentsProps) {
const [theme, setTheme] = useState(() => {
const currentTheme = localStorage.getItem("theme");
const browserTheme = window.matchMedia("(prefers-color-scheme: dark)")
.matches
? "dark"
: "light";

return currentTheme || browserTheme;
});

useEffect(() => {
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
const handleChange = ({ matches }: MediaQueryListEvent) => {
setTheme(matches ? "dark" : "light");
};

mediaQuery.addEventListener("change", handleChange);

return () => mediaQuery.removeEventListener("change", handleChange);
}, []);

useEffect(() => {
const themeButton = document.querySelector("#theme-btn");
const handleClick = () => {
setTheme(prevTheme => (prevTheme === "dark" ? "light" : "dark"));
};

themeButton?.addEventListener("click", handleClick);

return () => themeButton?.removeEventListener("click", handleClick);
}, []);

return (
<div className="mt-8">
<Giscus theme={theme === "light" ? lightTheme : darkTheme} {...GISCUS} />
</div>
);
}
14 changes: 14 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Site, SocialObjects } from "./types";
import type { GiscusProps } from "@giscus/react";

export const SITE: Site = {
website: "https://emeraldjava.github.io/", // replace this with your deployed domain
Expand Down Expand Up @@ -45,3 +46,16 @@ export const SOCIALS: SocialObjects = [
active: true,
},
];

export const GISCUS: GiscusProps = {
repo: "[ENTER REPO HERE]",
repoId: "[ENTER REPO ID HERE]",
category: "[ENTER CATEGORY NAME HERE]",
categoryId: "[ENTER CATEGORY ID HERE]",
mapping: "pathname",
reactionsEnabled: "0",
emitMetadata: "0",
inputPosition: "bottom",
lang: "en",
loading: "lazy",
};
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/content/blog/2024/2024-06-22-GA.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ description: "Upgrade of Google Analytics tags"
https://webreaper.dev/posts/astro-google-tag-manager-ga4/

https://tagmanager.google.com/#/container/accounts/6236586547/containers/188259084/workspaces/2

## update

Need to use is:inline to enable.
13 changes: 13 additions & 0 deletions src/layouts/PostDetails.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Datetime from "@components/Datetime";
import type { CollectionEntry } from "astro:content";
import { slugifyStr } from "@utils/slugify";
import ShareLinks from "@components/ShareLinks.astro";
import Comments from "@components/Comments";
import { SITE } from "@config";
export interface Props {
Expand Down Expand Up @@ -177,6 +178,18 @@ const nextPost =
)
}
</div>

<!--
https://github.com/giscus/giscus-component
https://github.com/satnaing/astro-paper/blob/main/src/content/blog/how-to-integrate-giscus-comments.md -->
<Comments client:only="react" />
<!--<script async src="https://giscus.app/client.js"-->
<!-- data-repo="[ENTER REPO HERE]"-->
<!-- data-repo-id="[ENTER REPO ID HERE]"-->
<!-- data-category="[ENTER CATEGORY NAME HERE]"-->
<!-- data-category-id="[ENTER CATEGORY ID HERE]">-->
<!--</script>-->

</main>
<Footer />
</Layout>
Expand Down

0 comments on commit 8bbe7fb

Please sign in to comment.