Skip to content

Commit b129642

Browse files
authored
fix: update main script (doocs#1705)
1 parent 71ece3f commit b129642

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

main.js

+21-30
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ window.addEventListener('hashchange', () => {
2424
window.$docsify = {
2525
name: 'leetcode',
2626
repo: 'doocs/leetcode',
27-
lastModifiedText: {
28-
'/README_EN': 'Last updated: ',
29-
'/': '最近更新时间:',
30-
},
31-
giscus: {
32-
repo: 'doocs/leetcode',
33-
repoId: 'MDEwOlJlcG9zaXRvcnkxNDkwMDEzNjU',
34-
category: 'Announcements',
35-
categoryId: 'DIC_kwDOCOGUlc4CZmhe',
36-
mapping: 'specific',
37-
term: getTerm(),
38-
reactionsEnabled: '0',
39-
strict: '1',
40-
emitMetadata: '0',
41-
inputPosition: 'top',
42-
crossorigin: 'anonymous',
43-
loading: 'lazy',
44-
theme: giscusTheme(),
45-
lang: getLang(),
46-
},
4727
logo: '/images/doocs-leetcode.png',
4828
search: {
4929
depth: 2,
@@ -70,6 +50,22 @@ window.$docsify = {
7050
'/solution/.*/summary_en.md': '/solution/summary_en.md',
7151
'/basic/.*/summary_en.md': '/basic/summary_en.md',
7252
},
53+
lastModifiedText: {
54+
'/README_EN': 'Last updated: ',
55+
'/': '最近更新时间:',
56+
},
57+
giscus: {
58+
repo: 'doocs/leetcode',
59+
repoId: 'MDEwOlJlcG9zaXRvcnkxNDkwMDEzNjU',
60+
category: 'Announcements',
61+
categoryId: 'DIC_kwDOCOGUlc4CZmhe',
62+
mapping: 'specific',
63+
reactionsEnabled: '0',
64+
strict: '1',
65+
emitMetadata: '0',
66+
inputPosition: 'top',
67+
crossorigin: 'anonymous',
68+
},
7369
contributors: {
7470
repo: 'doocs/leetcode',
7571
ignores: [
@@ -145,9 +141,7 @@ window.$docsify = {
145141
return html + footer;
146142
});
147143
hook.doneEach(() => {
148-
const term = getTerm();
149-
const lang = getLang();
150-
var giscusScript = document.createElement('script');
144+
const giscusScript = document.createElement('script');
151145
const {
152146
repo,
153147
repoId,
@@ -159,8 +153,6 @@ window.$docsify = {
159153
emitMetadata,
160154
inputPosition,
161155
crossorigin,
162-
loading,
163-
theme,
164156
} = $docsify.giscus;
165157
giscusScript.type = 'text/javascript';
166158
giscusScript.async = true;
@@ -175,11 +167,10 @@ window.$docsify = {
175167
giscusScript.setAttribute('data-emit-metadata', emitMetadata);
176168
giscusScript.setAttribute('data-input-position', inputPosition);
177169
giscusScript.setAttribute('crossorigin', crossorigin);
178-
giscusScript.setAttribute('data-loading', loading);
179-
giscusScript.setAttribute('data-theme', theme);
170+
giscusScript.setAttribute('data-theme', giscusTheme());
180171

181-
giscusScript.setAttribute('data-term', term);
182-
giscusScript.setAttribute('data-lang', lang);
172+
giscusScript.setAttribute('data-term', getTerm());
173+
giscusScript.setAttribute('data-lang', getLang());
183174

184175
document
185176
.getElementById('main')
@@ -188,7 +179,7 @@ window.$docsify = {
188179
document.getElementById('docsify-darklight-theme').addEventListener('click', () => {
189180
const frame = document.querySelector('.giscus-frame');
190181
frame.contentWindow.postMessage(
191-
{ giscus: { setConfig: { theme } } },
182+
{ giscus: { setConfig: { theme: giscusTheme() } } },
192183
'https://giscus.app',
193184
);
194185
});

0 commit comments

Comments
 (0)