Skip to content

Commit 778d0aa

Browse files
authored
Merge pull request #16 from sbamin/scratch
Scratch
2 parents 3dac23a + 4127837 commit 778d0aa

File tree

3 files changed

+91
-33
lines changed

3 files changed

+91
-33
lines changed

web/docs/assets/css/extra.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,27 @@ html .md-copyright {
4040
}
4141
.md-typeset .hourglass > .admonition-title::before,
4242
.md-typeset .hourglass > summary::before {
43-
background-color: rgb(0, 176, 255);
43+
background-color: #000000cc;
4444
-webkit-mask-image: var(--md-admonition-icon--hourglass);
4545
mask-image: var(--md-admonition-icon--hourglass);
4646
}
47+
48+
/*wip*/
49+
:root {
50+
--md-admonition-icon--wip: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path xmlns="http://www.w3.org/2000/svg" d="M501.1 395.7 384 278.6c-23.1-23.1-57.6-27.6-85.4-13.9L192 158.1V96L64 0 0 64l96 128h62.1l106.6 106.6c-13.6 27.8-9.2 62.3 13.9 85.4l117.1 117.1c14.6 14.6 38.2 14.6 52.7 0l52.7-52.7c14.5-14.6 14.5-38.2 0-52.7zM331.7 225c28.3 0 54.9 11 74.9 31l19.4 19.4c15.8-6.9 30.8-16.5 43.8-29.5 37.1-37.1 49.7-89.3 37.9-136.7-2.2-9-13.5-12.1-20.1-5.5l-74.4 74.4-67.9-11.3L334 98.9l74.4-74.4c6.6-6.6 3.4-17.9-5.7-20.2-47.4-11.7-99.6.9-136.6 37.9-28.5 28.5-41.9 66.1-41.2 103.6l82.1 82.1c8.1-1.9 16.5-2.9 24.7-2.9zm-103.9 82-56.7-56.7L18.7 402.8c-25 25-25 65.5 0 90.5s65.5 25 90.5 0l123.6-123.6c-7.6-19.9-9.9-41.6-5-62.7zM64 472c-13.2 0-24-10.8-24-24 0-13.3 10.7-24 24-24s24 10.7 24 24c0 13.2-10.7 24-24 24z"/></svg>')
51+
}
52+
.md-typeset .admonition.wip,
53+
.md-typeset details.wip {
54+
border-color: #64dd1799;
55+
}
56+
.md-typeset .wip > .admonition-title,
57+
.md-typeset .wip > summary {
58+
background-color: #64dd1799;
59+
border-color: #64dd1799;
60+
}
61+
.md-typeset .wip > .admonition-title::before,
62+
.md-typeset .wip > summary::before {
63+
background-color: #ff1744;
64+
-webkit-mask-image: var(--md-admonition-icon--wip);
65+
mask-image: var(--md-admonition-icon--wip);
66+
}

web/mkdocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ theme:
3636
- navigation.top
3737
- navigation.indexes
3838
- navigation.sections
39+
- content.code.annotate
3940
palette: #
4041
- scheme: default
4142
primary: blue
@@ -105,6 +106,11 @@ extra:
105106
version:
106107
provider: mike
107108
default: latest
109+
comments:
110+
enabled: true
111+
# defaults to utterances unless replaced mode: giscus
112+
mode: utterances
113+
type: issues
108114

109115
# Extensions
110116
markdown_extensions:

web/overrides/main.html

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,53 @@
6868
{% if page and page.meta and page.meta.author %}
6969
<p><small>Author: {{ page.meta.author }}</small></p>
7070
{% else %}
71-
<p><small>Author: <a href="https://sbamin.com/about" rel="me">{{ config.site_author }}</a> <span class="twemoji">
72-
{% include ".icons/fontawesome/brands/twitter.svg" %}
73-
</span><a href="https://twitter.com/{{config.extra.twitter}}">@{{config.extra.twitter}}</a></small></p>
71+
<p><small>Author: <a href="https://sbamin.com/about" rel="me">{{ config.site_author }}</a> <span class="twemoji">{% include ".icons/fontawesome/brands/twitter.svg" %}</span><a href="https://twitter.com/{{config.extra.twitter}}">@{{config.extra.twitter}}</a></small></p>
7472
{% endif %}
7573

76-
{% if page and page.meta and page.meta.comments %}
77-
<!-- Giscus -->
74+
{% if config.extra.comments.enabled and page and page.meta and page.meta.comments == false %}
75+
<!-- disbale comments -->
76+
{% else %}
7877
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
79-
<!-- Replace with generated snippet -->
80-
<script src="https://giscus.app/client.js"
81-
data-repo="sbamin/code101"
82-
data-repo-id="R_kgDOGmaCJg"
83-
data-category="Announcements"
84-
data-category-id="DIC_kwDOGmaCJs4CAeTc"
85-
data-mapping="pathname"
86-
data-reactions-enabled="1"
87-
data-emit-metadata="0"
88-
data-input-position="top"
89-
data-theme="light"
90-
data-lang="en"
91-
crossorigin="anonymous"
92-
async>
93-
</script>
78+
<p>Comments are powered by <span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></span> <a href="{{ config.repo_url }}{{ config.extra.comments.type }}">GitHub {{ config.extra.comments.type }}</a> and requires a login with a github id.</p>
79+
80+
{% if config.extra.comments.mode == "giscus" %}
81+
<script src="https://giscus.app/client.js"
82+
data-repo="sbamin/code101"
83+
data-repo-id="R_kgDOGmaCJg"
84+
data-category="Announcements"
85+
data-category-id="DIC_kwDOGmaCJs4CAeTc"
86+
data-mapping="pathname"
87+
data-reactions-enabled="1"
88+
data-emit-metadata="0"
89+
data-input-position="top"
90+
data-theme="light"
91+
data-lang="en"
92+
crossorigin="anonymous"
93+
async>
94+
</script>
95+
{% else %}
96+
<script src="https://utteranc.es/client.js"
97+
repo="sbamin/code101"
98+
issue-term="title"
99+
label="site issues :speech_balloon:"
100+
theme="github-light"
101+
crossorigin="anonymous"
102+
async>
103+
</script>
104+
{% endif %}
94105

95106
<!-- Reload on palette change -->
96107
<script>
97108
var palette = __md_get("__palette")
98109
if (palette && typeof palette.color === "object")
99110
if (palette.color.scheme === "slate") {
100-
var giscus = document.querySelector("script[src*=giscus]")
101-
giscus.setAttribute("data-theme", "dark")
111+
{% if config.extra.comments.mode == "giscus" %}
112+
var giscus = document.querySelector("script[src*=giscus]")
113+
giscus.setAttribute("data-theme", "dark")
114+
{% else %}
115+
var utterances = document.querySelector("script[src*=utteranc]")
116+
utterances.setAttribute("theme", "github-dark")
117+
{% endif %}
102118
}
103119

104120
/* Register event handlers after documented loaded */
@@ -107,20 +123,36 @@ <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
107123
ref.addEventListener("change", function() {
108124
var palette = __md_get("__palette")
109125
if (palette && typeof palette.color === "object") {
110-
var theme = palette.color.scheme === "slate" ? "dark" : "light"
111-
112-
/* Instruct Giscus to change theme */
113-
var frame = document.querySelector(".giscus-frame")
114-
frame.contentWindow.postMessage(
115-
{ giscus: { setConfig: { theme } } },
116-
"https://giscus.app"
117-
)
126+
// reload theme for either giscus or utterances
127+
{% if config.extra.comments.mode == "giscus" %}
128+
/* Instruct Giscus to change theme */
129+
var theme = palette.color.scheme === "slate" ? "dark" : "light"
130+
var frame = document.querySelector(".giscus-frame")
131+
frame.contentWindow.postMessage(
132+
{ giscus: { setConfig: { theme } } },
133+
"https://giscus.app"
134+
)
135+
{% else %}
136+
/* Instruct Utterances to change theme */
137+
// https://github.com/utterance/utterances/issues/549#issuecomment-907606127
138+
var frame = document.querySelector(".utterances-frame")
139+
var theme = palette.color.scheme === "slate" ? "github-dark" : "github-light"
140+
const message = {
141+
type: 'set-theme',
142+
theme: theme
143+
};
144+
const iframe = document.querySelector('.utterances-frame');
145+
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
146+
{% endif %}
118147
}
119148
})
120149
})
121150
</script>
122151
{% endif %}
123152

124-
<!-- <script src="{{config.site_url}}{{ 'assets/javascripts/bundle.93302429.min.js' | url }}"></script>
125-
<script src="{{config.site_url}}{{ 'assets/javascripts/bundle.71c96ae2.min.js' | url }}"></script> -->
153+
{# defunct scripts
154+
<script src="{{config.site_url}}{{ 'assets/javascripts/bundle.93302429.min.js' | url }}"></script>
155+
<script src="{{config.site_url}}{{ 'assets/javascripts/bundle.71c96ae2.min.js' | url }}"></script>
156+
#}
126157
{% endblock %}
158+

0 commit comments

Comments
 (0)