Skip to content

Commit 4ea6275

Browse files
committed
[Feat] Giscus 댓글 연결 및 favicon/open-graph 이미지 추가
1 parent 5c5d097 commit 4ea6275

12 files changed

Lines changed: 157 additions & 29 deletions

.github/workflows/deploy.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
# GitHub의 Actions 탭에서 이 워크플로를 수동으로 실행할 수 있습니다.
7+
workflow_dispatch:
8+
9+
# 이 작업이 리포지토리를 복제하고 페이지 배포를 생성하도록 허용합니다.
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout your repository using git
20+
uses: actions/checkout@v6
21+
- name: Install, build, and upload your site
22+
uses: withastro/action@v6
23+
# with:
24+
# path: . # 저장소 내 Astro 프로젝트의 루트 위치입니다. (선택 사항)
25+
# node-version: 24 # 사이트를 빌드하는 데 사용해야 하는 특정 버전의 Node입니다. 기본값은 22입니다. (선택 사항)
26+
# package-manager: pnpm@latest # 종속성을 설치하고 사이트를 빌드하는 데 사용해야 하는 노드 패키지 관리자입니다. lockfile을 기반으로 자동으로 감지됩니다. (선택 사항)
27+
# build-cmd: pnpm run build # 사이트를 빌드하는 데 실행할 명령입니다. 기본적으로 패키지 빌드 스크립트/작업을 실행합니다. (선택 사항)
28+
# env:
29+
# PUBLIC_POKEAPI: 'https://pokeapi.co/api/v2' # 변수 값에는 작은따옴표를 사용합니다. (선택 사항)
30+
31+
deploy:
32+
needs: build
33+
runs-on: ubuntu-latest
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
steps:
38+
- name: Deploy to GitHub Pages
39+
id: deployment
40+
uses: actions/deploy-pages@v5

public/css/giscus-custom.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
main {
2+
--color-text-primary: var(--text);
3+
--color-fg-default: var(--text);
4+
}
5+
6+
.gsc-main {
7+
gap: 0.6em;
8+
}
9+
10+
.gsc-comments {
11+
gap: 0.2em;
12+
}
13+
14+
.gsc-comments-count {
15+
font-size: 1.1em;
16+
}

public/favicon.ico

10.4 KB
Binary file not shown.

public/favicon.svg

Lines changed: 3 additions & 8 deletions
Loading

public/tpo-social-share.png

11.8 KB
Loading

src/components/Comments.astro

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
const customCss = new URL("/css/giscus-custom.css", Astro.site).href;
3+
---
4+
5+
<section class="comments">
6+
<script
7+
is:inline
8+
src="https://giscus.app/client.js"
9+
data-repo="aaronryu/aaronryu.github.io"
10+
data-repo-id="MDEwOlJlcG9zaXRvcnkxNjMwOTgxOTc="
11+
data-category="Announcements"
12+
data-category-id="DIC_kwDOCbiuVc4C8t_o"
13+
data-mapping="pathname"
14+
data-strict="0"
15+
data-reactions-enabled="1"
16+
data-emit-metadata="0"
17+
data-input-position="top"
18+
data-theme={customCss}
19+
data-lang="ko"
20+
data-loading="lazy"
21+
crossorigin="anonymous"
22+
async
23+
>
24+
</script>
25+
<!-- preferred_color_scheme -->
26+
</section>
27+
28+
<script is:inline>
29+
function getGiscusTheme() {
30+
return document.documentElement.classList.contains("dark") ? "dark" : "light";
31+
}
32+
33+
function sendGiscusTheme(theme) {
34+
const iframe = document.querySelector("iframe.giscus-frame");
35+
if (!iframe) return false;
36+
37+
iframe.contentWindow.postMessage(
38+
{ giscus: { setConfig: { theme: theme } } },
39+
"https://giscus.app",
40+
);
41+
return true;
42+
}
43+
44+
// 다크 모드 토글을 감지
45+
// + 중복 등록 방지: 이미 observer 가 있으면 스킵
46+
if (!window.__giscusObserver) {
47+
window.__giscusObserver = new MutationObserver(() => {
48+
sendGiscusTheme(getGiscusTheme());
49+
});
50+
51+
window.__giscusObserver.observe(document.documentElement, {
52+
attributes: true,
53+
attributeFilter: ["class"],
54+
});
55+
}
56+
57+
// Lazy Loading 방식으로 Giscus 댓글창을 로드하기에 그것이 완료되었을때 현재 테마설정을 읽어 사용하도록
58+
window.addEventListener("message", (event) => {
59+
if (event.origin !== "https://giscus.app") return;
60+
if (!(typeof event.data === "object" && event.data.giscus)) return;
61+
62+
// Giscus sends a message when it's finished loading
63+
sendGiscusTheme(getGiscusTheme());
64+
});
65+
</script>
66+
67+
<script></script>

src/components/Footer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const currentYear = new Date().getFullYear();
149149
.wsj-logo {
150150
font-family: "Times New Roman", Times, serif;
151151
font-size: 1.4em;
152-
font-weight: 900;
152+
font-weight: 600;
153153
line-height: 0.9em;
154154
letter-spacing: -0.5px;
155155
text-align: start;

src/components/Header.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const totalYears = diff / (1000 * 60 * 60 * 24 * 365.25);
214214
.wsj-logo {
215215
font-family: "Times New Roman", Times, serif;
216216
font-size: 2.4em;
217-
font-weight: 900;
217+
font-weight: 600;
218218
line-height: 0.9em;
219219
letter-spacing: -0.5px;
220220
text-align: center;

src/components/OnScrollStickyHeader.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const translatePath = useTranslatedPath(lang);
5656
.on-scroll-sticky-header .logo {
5757
font-family: "Times New Roman", Times, serif;
5858
font-size: 1.6em;
59-
font-weight: 900;
59+
font-weight: 600;
6060
letter-spacing: -0.5px;
6161
text-align: center;
6262

src/layouts/BaseLayout.astro

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ const {
2727
author = AARON,
2828
keywords = AARONS_BLOG_KEYWORDS[lang as Lang],
2929
description = AARONS_BLOG_DESCRIPTION[lang as Lang],
30-
image = "",
30+
image,
3131
section,
3232
created,
3333
updated,
3434
} = Astro.props;
3535
36+
const ogImageUrl = new URL('/tpo-social-share.png', Astro.site).href;
37+
3638
const isArticle = title !== AARONS_BLOG_TITLE && !!created;
3739
const isProd = import.meta.env.PROD;
3840
const isDev = import.meta.env.DEV;
@@ -93,13 +95,9 @@ const jaURL = new URL(languageURL.ja, Astro.site).href;
9395
)
9496
}
9597
<meta property="og:url" content="https://aaron.github.io/" />
96-
<!-- TODO <meta property="og:image" content="https://aaron.github.io/images/og.png" /> -->
98+
<meta property="og:image" content={image ?? ogImageUrl} />
9799
<meta name="twitter:card" content="summary_large_image" />
98100
<meta name="twitter:site" content={AARONS_TWITTER_ACCOUNT} />
99-
<meta name="twitter:creator" content={AARONS_TWITTER_ACCOUNT} />
100-
<meta name="twitter:title" content={title} />
101-
<meta name="twitter:description" content={description} />
102-
<!-- TODO <meta name="twitter:image" content="https://aaron.github.io/images/og.png" /> -->
103101
<!-- (C.1) SEO 개선을 위한 Canonical 설정 - 원본 페이지 주소 명시 -->
104102
<!-- 현재 페이지의 절대 경로를 가리킴 -->
105103
<link rel="canonical" href={canonicalURL} />

0 commit comments

Comments
 (0)