Skip to content

Commit f45febf

Browse files
authored
Merge pull request #3 from sofianlak/feature/add-giscus
feat: add giscus, fix some issues on config, change YT contact
2 parents 8782c8e + 2ea8a2e commit f45febf

3 files changed

Lines changed: 69 additions & 16 deletions

File tree

_config.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ webmaster_verifications:
5252
analytics:
5353
google:
5454
id: G-LXE8NNY5CR
55-
goatcounter:
56-
id: sofianlak
5755
umami:
5856
id: # fill in your Umami ID
5957
domain: # fill in your Umami domain
@@ -98,7 +96,7 @@ toc: true
9896

9997
comments:
10098
# Global switch for the post comment system. Keeping it empty means disabled.
101-
provider: # [disqus | utterances | giscus]
99+
provider: giscus # [disqus | utterances | giscus]
102100
# The provider options are as follows:
103101
disqus:
104102
shortname: sofianlak # fill with the Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname
@@ -108,14 +106,15 @@ comments:
108106
issue_term: # < url | pathname | title | ...>
109107
# Giscus options › https://giscus.app
110108
giscus:
111-
repo: # <gh-username>/<repo>
112-
repo_id:
113-
category:
114-
category_id:
115-
mapping: # optional, default to 'pathname'
116-
input_position: # optional, default to 'bottom'
117-
lang: # optional, default to the value of `site.lang`
118-
reactions_enabled: # optional, default to the value of `1`
109+
repo: sofianlak/sofianlak.github.io
110+
repo_id: R_kgDOLsWVGA
111+
category: General
112+
category_id: DIC_kwDOLsWVGM4CzeUO
113+
mapping: pathname
114+
input_position: bottom
115+
theme: light
116+
lang: en
117+
reactions_enabled: 1
119118

120119
# Self-hosted static assets, optional › https://github.com/cotes2020/chirpy-static-assets
121120
assets:
@@ -189,7 +188,7 @@ defaults:
189188
values:
190189
swcache: true
191190

192-
ass:
191+
sass:
193192
style: compressed
194193
sourcemap: never
195194
quiet_deps: true

_data/contact.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
icon: "fab fa-github"
55

66
- type: linkedin
7-
icon: "fab fa-linkedin" # icons powered by <https://fontawesome.com/>
8-
url: "https://www.linkedin.com/in/sofianlakhdar/" # Fill with your Linkedin homepage
9-
7+
icon: "fab fa-linkedin" # icons powered by <https://fontawesome.com/>
8+
url: "https://www.linkedin.com/in/sofianlakhdar/" # Fill with your Linkedin homepage
109

1110
- type: youtube
1211
icon: "fab fa-youtube"
13-
url: "https://www.youtube.com/@sre-and-cie"
12+
url: "https://www.youtube.com/@sofianlak"
1413

1514
#- type: twitter
1615
# icon: "fa-brands fa-x-twitter"

_includes/comments/giscus.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!-- Custom giscus embed (light theme forced) based on Chirpy default -->
2+
<script>
3+
(function () {
4+
// Force light theme for giscus regardless of site theme
5+
const themeMapper = Theme.getThemeMapper('light', 'light');
6+
const initTheme = themeMapper[Theme.visualState];
7+
8+
let lang = '{{ site.comments.giscus.lang | default: lang }}';
9+
if (lang.length > 2 && !lang.startsWith('zh')) {
10+
lang = lang.slice(0, 2);
11+
}
12+
13+
const giscusAttributes = {
14+
src: 'https://giscus.app/client.js',
15+
'data-repo': '{{ site.comments.giscus.repo}}',
16+
'data-repo-id': '{{ site.comments.giscus.repo_id }}',
17+
'data-category': '{{ site.comments.giscus.category }}',
18+
'data-category-id': '{{ site.comments.giscus.category_id }}',
19+
'data-mapping': '{{ site.comments.giscus.mapping | default: 'pathname' }}',
20+
'data-strict' : '{{ site.comments.giscus.strict | default: '0' }}',
21+
'data-reactions-enabled': '{{ site.comments.giscus.reactions_enabled | default: '1' }}',
22+
'data-emit-metadata': '0',
23+
'data-theme': initTheme,
24+
'data-input-position': '{{ site.comments.giscus.input_position | default: 'bottom' }}',
25+
'data-lang': lang,
26+
'data-loading': 'lazy',
27+
crossorigin: 'anonymous',
28+
async: ''
29+
};
30+
31+
const giscusNode = document.createElement('script');
32+
Object.entries(giscusAttributes).forEach(([key, value]) =>
33+
giscusNode.setAttribute(key, value)
34+
);
35+
36+
const $footer = document.querySelector('footer');
37+
$footer.insertAdjacentElement("beforebegin", giscusNode);
38+
39+
addEventListener('message', (event) => {
40+
if (event.source === window && event.data && event.data.id === Theme.ID) {
41+
const newTheme = themeMapper[Theme.visualState];
42+
43+
const message = {
44+
setConfig: {
45+
theme: newTheme
46+
}
47+
};
48+
49+
const giscus =
50+
document.getElementsByClassName('giscus-frame')[0].contentWindow;
51+
giscus.postMessage({ giscus: message }, 'https://giscus.app');
52+
}
53+
});
54+
})();
55+
</script>

0 commit comments

Comments
 (0)