chore: restore popular posts

This commit is contained in:
Cory Dransfeldt 2023-08-26 19:42:28 -07:00
parent 713c3c219e
commit 5d637ee7b7
No known key found for this signature in database
7 changed files with 27 additions and 5 deletions

View file

@ -18,3 +18,5 @@ permalink: 404.html
</a>
</div>
</div>
<hr />
{% render "partials/popular-posts.liquid", posts: collections.posts, analytics: analytics %}

14
src/_data/analytics.js Normal file
View file

@ -0,0 +1,14 @@
const EleventyFetch = require('@11ty/eleventy-fetch')
module.exports = async function () {
const SITE_ID_CLICKY = process.env.SITE_ID_CLICKY
const SITE_KEY_CLICKY = process.env.SITE_KEY_CLICKY
const url = `https://api.clicky.com/api/stats/4?site_id=${SITE_ID_CLICKY}&sitekey=${SITE_KEY_CLICKY}&type=pages&output=json`
const res = EleventyFetch(url, {
duration: '1h',
type: 'json',
}).catch()
const data = await res
const pages = data[0].dates[0].items
return pages.filter((p) => p.url.includes('posts'))
}

View file

@ -13,4 +13,5 @@ layout: main
</article>
{% render "partials/post-tags.liquid", tags: tags %}
{% render "partials/webmentions/container.liquid", webmentions: webmentions, page: page %}
{% render "partials/author.liquid", site: site %}
{% render "partials/author.liquid", site: site %}
{% render "partials/popular-posts.liquid", posts: collections.posts, analytics: analytics %}

View file

@ -35,4 +35,5 @@ meta:
}
</style>
<div id="search" class="search"></div>
<script src="https://coryd.dev/_pagefind/pagefind-ui.js" onload="new PagefindUI({ element: '#search', showImages: false, processTerm: (term) => {clicky.log('/search', term, 'pageview');} });"></script>
<script src="https://coryd.dev/_pagefind/pagefind-ui.js" onload="new PagefindUI({ element: '#search', showImages: false, processTerm: (term) => {clicky.log('/search', term, 'pageview');} });"></script>
{% render "partials/popular-posts.liquid", posts: collections.posts, analytics: analytics %}