footer.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {{- if not (.Param "hideFooter") }}
  2. <footer class="footer">
  3. {{- if site.Copyright }}
  4. <span>{{ site.Copyright | markdownify }}</span>
  5. {{- else }}
  6. <span>&copy; {{ now.Year }} <a href="{{ "" | absLangURL }}">{{ site.Title }}</a></span>
  7. {{- end }}
  8. <span>
  9. Powered by
  10. <a href="https://gohugo.io/" rel="noopener noreferrer" target="_blank">Hugo</a> &
  11. <a href="https://github.com/adityatelange/hugo-PaperMod/" rel="noopener" target="_blank">PaperMod</a>
  12. </span>
  13. </footer>
  14. {{- end }}
  15. {{- if (not site.Params.disableScrollToTop) }}
  16. <a href="#top" aria-label="go to top" title="Go to Top (Alt + G)" class="top-link" id="top-link" accesskey="g">
  17. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentColor">
  18. <path d="M12 6H0l6-6z" />
  19. </svg>
  20. </a>
  21. {{- end }}
  22. {{- partial "extend_footer.html" . }}
  23. <script>
  24. let menu = document.getElementById('menu')
  25. if (menu) {
  26. menu.scrollLeft = localStorage.getItem("menu-scroll-position");
  27. menu.onscroll = function () {
  28. localStorage.setItem("menu-scroll-position", menu.scrollLeft);
  29. }
  30. }
  31. document.querySelectorAll('a[href^="#"]').forEach(anchor => {
  32. anchor.addEventListener("click", function (e) {
  33. e.preventDefault();
  34. var id = this.getAttribute("href").substr(1);
  35. if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
  36. document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
  37. behavior: "smooth"
  38. });
  39. } else {
  40. document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
  41. }
  42. if (id === "top") {
  43. history.replaceState(null, null, " ");
  44. } else {
  45. history.pushState(null, null, `#${id}`);
  46. }
  47. });
  48. });
  49. </script>
  50. {{- if (not site.Params.disableScrollToTop) }}
  51. <script>
  52. var mybutton = document.getElementById("top-link");
  53. window.onscroll = function () {
  54. if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) {
  55. mybutton.style.visibility = "visible";
  56. mybutton.style.opacity = "1";
  57. } else {
  58. mybutton.style.visibility = "hidden";
  59. mybutton.style.opacity = "0";
  60. }
  61. };
  62. </script>
  63. {{- end }}
  64. {{- if (not site.Params.disableThemeToggle) }}
  65. <script>
  66. document.getElementById("theme-toggle").addEventListener("click", () => {
  67. if (document.body.className.includes("dark")) {
  68. document.body.classList.remove('dark');
  69. localStorage.setItem("pref-theme", 'light');
  70. } else {
  71. document.body.classList.add('dark');
  72. localStorage.setItem("pref-theme", 'dark');
  73. }
  74. })
  75. </script>
  76. {{- end }}
  77. {{- if (and (eq .Kind "page") (ne .Layout "archives") (ne .Layout "search") (.Param "ShowCodeCopyButtons")) }}
  78. <script>
  79. document.querySelectorAll('pre > code').forEach((codeblock) => {
  80. const container = codeblock.parentNode.parentNode;
  81. const copybutton = document.createElement('button');
  82. copybutton.classList.add('copy-code');
  83. copybutton.innerHTML = '{{- i18n "code_copy" | default "copy" }}';
  84. function copyingDone() {
  85. copybutton.innerHTML = '{{- i18n "code_copied" | default "copied!" }}';
  86. setTimeout(() => {
  87. copybutton.innerHTML = '{{- i18n "code_copy" | default "copy" }}';
  88. }, 2000);
  89. }
  90. copybutton.addEventListener('click', (cb) => {
  91. if ('clipboard' in navigator) {
  92. navigator.clipboard.writeText(codeblock.textContent);
  93. copyingDone();
  94. return;
  95. }
  96. const range = document.createRange();
  97. range.selectNodeContents(codeblock);
  98. const selection = window.getSelection();
  99. selection.removeAllRanges();
  100. selection.addRange(range);
  101. try {
  102. document.execCommand('copy');
  103. copyingDone();
  104. } catch (e) { };
  105. selection.removeRange(range);
  106. });
  107. if (container.classList.contains("highlight")) {
  108. container.appendChild(copybutton);
  109. } else if (container.parentNode.firstChild == container) {
  110. // td containing LineNos
  111. } else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") {
  112. // table containing LineNos and code
  113. codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton);
  114. } else {
  115. // code blocks not having highlight as parent class
  116. codeblock.parentNode.appendChild(copybutton);
  117. }
  118. });
  119. </script>
  120. {{- end }}