This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
coryd.dev-eleventy/src/_data/analytics.js
2024-04-06 14:54:07 -07:00

14 lines
No EOL
523 B
JavaScript

import EleventyFetch from '@11ty/eleventy-fetch'
export default 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'))
}