-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #4
- Loading branch information
Showing
12 changed files
with
186 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BASE_URL=/blog/ | ||
# GISCUS Configs: generated from https://giscus.app/ | ||
GISCUS_REPO_ID= | ||
GISCUS_CATEGORY_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
.env | ||
.vitepress/dist | ||
.vitepress/cache | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import "dotenv/config"; | ||
import { env } from "process"; | ||
import * as path from "path"; | ||
|
||
export const BASE_URL = env.BASE_URL || undefined; | ||
|
||
export const giscus = { | ||
repo_id: env.GISCUS_REPO_ID || "", | ||
category_id: env.GISCUS_CATEGORY_ID || "", | ||
}; | ||
|
||
export function withBaseURL(urlPath: string) { | ||
return path.join(BASE_URL || "/", urlPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<div :class="$style.giscus"> | ||
<Giscus | ||
v-if="giscusOptions.show" | ||
repo="Octobug/blog" | ||
:repo-id="giscus.repo_id" | ||
category="Announcements" | ||
:category-id="giscus.category_id" | ||
mapping="title" | ||
strict="1" | ||
reactions-enabled="1" | ||
emit-metadata="0" | ||
input-position="top" | ||
:theme="giscusOptions.theme" | ||
lang="en" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import Giscus from "@giscus/vue"; | ||
import { onContentUpdated, useData } from "vitepress"; | ||
import { ref } from "vue"; | ||
const { isDark, theme } = useData(); | ||
const { giscus } = theme.value; | ||
function getGiscusTheme() { | ||
return isDark.value ? "dark" : "light"; | ||
} | ||
const giscusOptions = ref({ | ||
theme: getGiscusTheme(), | ||
show: false, | ||
}); | ||
function reloadGiscus() { | ||
// I cannot tolerate the color flash when switching, so I choose to reload it. | ||
giscusOptions.value = { | ||
theme: getGiscusTheme(), | ||
show: false | ||
}; | ||
setTimeout(() => { | ||
giscusOptions.value.show = true; | ||
}, 1); | ||
} | ||
onContentUpdated(() => { | ||
reloadGiscus(); | ||
const observer = new MutationObserver(reloadGiscus); | ||
const element = document.querySelector("button.VPSwitchAppearance"); | ||
if (!element) return; | ||
observer.observe(element, { attributes: true }); | ||
}); | ||
</script> | ||
|
||
<style module scoped> | ||
.giscus { | ||
margin-top: 1.5rem; | ||
display: grid; | ||
grid-row-gap: 8px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters