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

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'))
}