Skip to content

Commit

Permalink
fix: fix giscus theme issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 25, 2024
1 parent ed2844e commit 775854c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/markdown/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ export async function createHTML(mdStr: string = '', fromPath: string, toPath: s

if (config.data.giscus) {
const resultGiscus = Object.keys(config.data.giscus).map((key) => `${key}="${config.data.giscus[key]}"`);
varData.giscusScript = `<script ${resultGiscus.join(' ')}></script><div class=".giscus"></div>`;
varData.giscusScript = `<script ${resultGiscus.join(
' ',
)} data-script-id="giscus"></script><div class=".giscus"></div>`;
}
let tempPath = path.resolve(config.data.theme, page.layout || 'markdown.ejs');
if (page.layout) {
Expand Down
4 changes: 3 additions & 1 deletion themes/default/js/giscus.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
},
}
};
iframe.contentWindow.postMessage(config, 'https://giscus.app');
iframe.contentWindow.postMessage(config, 'https://giscus.app');
const script = document.querySelector("script[data-script-id=\"giscus\"]")
script.setAttribute("data-theme", theme)
}
}
})();

0 comments on commit 775854c

Please sign in to comment.