blog

Log | Files | Refs

footer.html (6124B)


      1 {{- if not (.Param "hideFooter") }}
      2 <footer class="footer">
      3     {{- if not site.Params.footer.hideCopyright }}
      4         {{- if site.Copyright }}
      5         <span>{{ site.Copyright | markdownify }}</span>
      6         {{- else }}
      7         <span>&copy; {{ now.Year }} <a href="{{ "" | absLangURL }}">{{ site.Title }}</a></span>
      8         {{- end }}
      9         {{- print " · "}}
     10     {{- end }}
     11 
     12     {{- with site.Params.footer.text }}
     13         {{ . | markdownify }}
     14         {{- print " · "}}
     15     {{- end }}
     16 
     17     {{/*
     18         - The "Powered by Hugo" text is intentionally left at the end of the footer to give it more prominence.
     19         - We kindly encourage you to keep this line. Keeping this credit helps open source projects like PaperMod and Hugo reach more people, supports the open source ecosystem, and shows appreciation for the work that goes into these tools.
     20         - If you choose to remove it, please consider adding a link to the PaperMod GitHub repository somewhere on your site to give credit to the project and its contributors.
     21         - Support us by sponsoring the project on GitHub Sponsors: https://github.com/sponsors/adityatelange
     22     */}}
     23     
     24     <span>
     25         Powered by
     26         <a href="https://gohugo.io/?utm_source=papermod" rel="noopener" target="_blank">Hugo</a> &
     27         <a href="https://github.com/adityatelange/hugo-PaperMod/" rel="noopener" target="_blank">PaperMod</a>
     28     </span>
     29 </footer>
     30 {{- end }}
     31 
     32 {{- if (not site.Params.disableScrollToTop) }}
     33 <a href="#top" id="top-link" class="top-link hidden" aria-label="go to top" title="Go to Top (Alt + G)" accesskey="g">
     34     <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
     35         stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevrons-up">
     36         <polyline points="17 11 12 6 7 11"></polyline>
     37         <polyline points="17 18 12 13 7 18"></polyline>
     38     </svg>
     39 </a>
     40 {{- end }}
     41 
     42 {{- partial "extend_footer.html" . }}
     43 
     44 <script>
     45     let menu = document.getElementById('menu');
     46     if (menu) {
     47         // Set the scroll position
     48         const scrollPosition = localStorage.getItem("menu-scroll-position");
     49         if (scrollPosition) {
     50             menu.scrollLeft = parseInt(scrollPosition, 10);
     51         }
     52         
     53         menu.onscroll = function () {
     54             localStorage.setItem("menu-scroll-position", menu.scrollLeft);
     55         }
     56     }
     57 
     58     document.querySelectorAll('a[href^="#"]').forEach(anchor => {
     59         anchor.addEventListener("click", function (e) {
     60             e.preventDefault();
     61             var id = this.getAttribute("href").substr(1);
     62             if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
     63                 document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
     64                     behavior: "smooth"
     65                 });
     66             } else {
     67                 document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
     68             }
     69             if (id === "top") {
     70                 history.replaceState(null, null, " ");
     71             } else {
     72                 history.pushState(null, null, `#${id}`);
     73             }
     74         });
     75     });
     76 
     77 </script>
     78 
     79 {{- if (not site.Params.disableScrollToTop) }}
     80 <script>
     81     var toplink = document.getElementById("top-link");
     82     window.onscroll = function () {
     83         const scrollThreshold = window.innerHeight;
     84         if (document.body.scrollTop > scrollThreshold || document.documentElement.scrollTop > scrollThreshold) {
     85             toplink.classList.remove("hidden");
     86         } else {
     87             toplink.classList.add("hidden");
     88         }
     89     };
     90 
     91 </script>
     92 {{- end }}
     93 
     94 {{- if (not site.Params.disableThemeToggle) }}
     95 <script>
     96     document.getElementById("theme-toggle").addEventListener("click", () => {
     97         const html = document.querySelector("html");
     98         if (html.dataset.theme === "dark") {
     99             html.dataset.theme = 'light';
    100             localStorage.setItem("pref-theme", 'light');
    101         } else {
    102             html.dataset.theme = 'dark';
    103             localStorage.setItem("pref-theme", 'dark');
    104         }
    105     })
    106 
    107 </script>
    108 {{- end }}
    109 
    110 {{- if (and (eq .Kind "page") (ne .Layout "archives") (ne .Layout "search") (.Param "ShowCodeCopyButtons")) }}
    111 <script>
    112     document.querySelectorAll('pre > code').forEach((codeblock) => {
    113         const container = codeblock.parentNode.parentNode;
    114 
    115         const copybutton = document.createElement('button');
    116         copybutton.classList.add('copy-code');
    117         copybutton.innerHTML = '{{- i18n "code_copy" | default "copy" }}';
    118 
    119         function copyingDone() {
    120             copybutton.innerHTML = '{{- i18n "code_copied" | default "copied!" }}';
    121             setTimeout(() => {
    122                 copybutton.innerHTML = '{{- i18n "code_copy" | default "copy" }}';
    123             }, 2000);
    124         }
    125 
    126         copybutton.addEventListener('click', (cb) => {
    127             if ('clipboard' in navigator) {
    128                 navigator.clipboard.writeText(codeblock.textContent);
    129                 copyingDone();
    130                 return;
    131             }
    132 
    133             const range = document.createRange();
    134             range.selectNodeContents(codeblock);
    135             const selection = window.getSelection();
    136             selection.removeAllRanges();
    137             selection.addRange(range);
    138             try {
    139                 document.execCommand('copy');
    140                 copyingDone();
    141             } catch (e) { };
    142             selection.removeRange(range);
    143         });
    144 
    145         if (container.classList.contains("highlight")) {
    146             container.appendChild(copybutton);
    147         } else if (container.parentNode.firstChild == container) {
    148             // td containing LineNos
    149         } else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") {
    150             // table containing LineNos and code
    151             codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton);
    152         } else {
    153             // code blocks not having highlight as parent class
    154             codeblock.parentNode.appendChild(copybutton);
    155         }
    156     });
    157 </script>
    158 {{- end }}