comments.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!--
  2. Copyright (c) 2016-2023 Martin Donath <martin.donath@squidfunk.com>
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to
  5. deal in the Software without restriction, including without limitation the
  6. rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  7. sell copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  16. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  17. IN THE SOFTWARE.
  18. -->
  19. <!-- Comment system -->
  20. {% if page.meta.comments %}
  21. <h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
  22. <!-- Insert generated snippet here -->
  23. <script src="https://giscus.app/client.js"
  24. data-repo="Wcowin/Mkdocs-Wcowin"
  25. data-repo-id="R_kgDOKf920A"
  26. data-category="Show and tell"
  27. data-category-id="DIC_kwDOKf920M4CaHEM"
  28. data-mapping="pathname"
  29. data-strict="0"
  30. data-reactions-enabled="1"
  31. data-emit-metadata="0"
  32. data-input-position="bottom"
  33. data-theme="light"
  34. data-lang="zh-CN"
  35. crossorigin="anonymous"
  36. async>
  37. </script>
  38. <!-- Synchronize Giscus theme with palette -->
  39. <script>
  40. var giscus = document.querySelector("script[src*=giscus]")
  41. // Set palette on initial load
  42. var palette = __md_get("__palette")
  43. if (palette && typeof palette.color === "object") {
  44. var theme = palette.color.scheme === "slate"
  45. ? "transparent_dark"
  46. : "light"
  47. // Instruct Giscus to set theme
  48. giscus.setAttribute("data-theme", theme)
  49. }
  50. // Register event handlers after documented loaded
  51. document.addEventListener("DOMContentLoaded", function() {
  52. var ref = document.querySelector("[data-md-component=palette]")
  53. ref.addEventListener("change", function() {
  54. var palette = __md_get("__palette")
  55. if (palette && typeof palette.color === "object") {
  56. var theme = palette.color.scheme === "slate"
  57. ? "transparent_dark"
  58. : "light"
  59. // Instruct Giscus to change theme
  60. var frame = document.querySelector(".giscus-frame")
  61. frame.contentWindow.postMessage(
  62. { giscus: { setConfig: { theme } } },
  63. "https://giscus.app"
  64. )
  65. }
  66. })
  67. })
  68. </script>
  69. {% endif %}