Jacky Zhao
2022-02-16 3b3e6ec3b2a56ee4d03b6f4c84af886821bfbe84
layouts/partials/head.html
@@ -26,24 +26,33 @@
    <!--  Preload page vars  -->
    <script>
      let saved = false
    const fetchData = async () => {
        if (saved) {
          return saved
        } else {
      const promises = [
        fetch("/linkIndex.json")
            fetch("{{ .Site.BaseURL }}/linkIndex.json")
          .then(data => data.json())
          .then(data => ({
            index: data.index,
            links: data.links,
          })),
        fetch("/contentIndex.json")
            fetch("{{ .Site.BaseURL }}/contentIndex.json")
          .then(data => data.json()),
      ]
      const [{index, links}, content] = await Promise.all(promises)
      return ({
          const res = ({
        index,
        links,
        content,
      })
          saved = res
          return res
    }
      }
      fetchData()
    </script>
</head>
{{ template "_internal/google_analytics.html" . }}