diff --git a/.env b/.env index 56f3cf42..c5481b3b 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ API_KEY_LASTFM= -API_KEY_PLAUSIBLE= +API_KEY_FATHOM= API_KEY_TRAKT= API_KEY_WEBMENTIONS_CORYD_DEV= API_TOKEN_READWISE= diff --git a/config/filters.js b/config/filters.js index d706bbd2..16c44ff1 100644 --- a/config/filters.js +++ b/config/filters.js @@ -28,10 +28,10 @@ module.exports = { getPopularPosts: (posts, analytics) => { return posts .filter((post) => { - if (analytics.find((p) => p.page === post.url)) return true + if (analytics.find((p) => p.pathname === post.url)) return true }) .sort((a, b) => { - const visitors = (page) => analytics.filter((p) => p.page === page.url).pop().visitors + const visitors = (page) => analytics.filter((p) => p.pathname === page.url).pop().visitors return visitors(b) - visitors(a) }) }, diff --git a/src/_data/analytics.js b/src/_data/analytics.js index 200e3da1..f2590f15 100644 --- a/src/_data/analytics.js +++ b/src/_data/analytics.js @@ -1,18 +1,18 @@ const EleventyFetch = require('@11ty/eleventy-fetch') module.exports = async function () { - const API_KEY_PLAUSIBLE = process.env.API_KEY_PLAUSIBLE + const API_KEY_FATHOM = process.env.API_KEY_FATHOM const url = - 'https://plausible.io/api/v1/stats/breakdown?site_id=coryd.dev&period=6mo&property=event:page&limit=30' + 'https://api.usefathom.com/v1/aggregations?entity=pageview&entity_id=RBCOWZTA&aggregates=pageviews&field_grouping=pathname&sort_by=pageviews:desc&limit=10' const res = EleventyFetch(url, { duration: '1h', type: 'json', fetchOptions: { headers: { - Authorization: `Bearer ${API_KEY_PLAUSIBLE}`, + Authorization: `Bearer ${API_KEY_FATHOM}`, }, }, }).catch() const pages = await res - return pages.results.filter((p) => p.page.includes('posts')).splice(0, 5) + return pages.filter((p) => p.pathname.includes('posts')) } diff --git a/src/_includes/partials/popular-posts.liquid b/src/_includes/partials/popular-posts.liquid index 4b610ab8..3912ec36 100644 --- a/src/_includes/partials/popular-posts.liquid +++ b/src/_includes/partials/popular-posts.liquid @@ -5,7 +5,7 @@
Popular posts
- + \ No newline at end of file