diff --git a/.env b/.env index 471ea57b..4840fddb 100644 --- a/.env +++ b/.env @@ -2,8 +2,7 @@ ACCESS_KEY_B2= SECRET_KEY_B2= BUCKET_B2= API_KEY_LASTFM= -SITE_ID= -API_KEY_NETLIFY= +API_KEY_FATHOM= API_KEY_TRAKT= API_KEY_MOVIEDB= API_TOKEN_READWISE= diff --git a/config/filters/index.js b/config/filters/index.js index 6f9bb6a9..4f3b6a0a 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -47,11 +47,11 @@ export default { getPopularPosts: (posts, analytics) => { return posts .filter((post) => { - if (analytics.find((p) => p.resource === post.url)) return true + if (analytics.find((p) => p.pathname === post.url)) return true }) .sort((a, b) => { - const count = (page) => analytics.filter((p) => p.resource === page.url).pop().count - return count(b) - count(a) + const visitors = (page) => analytics.filter((p) => p.pathname === page.url).pop().visitors + return visitors(b) - visitors(a) }) }, diff --git a/package.json b/package.json index 807d4f47..10fca9eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "8.5.1", + "version": "8.6.1", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/analytics.js b/src/_data/analytics.js index 18661548..322cb3fa 100644 --- a/src/_data/analytics.js +++ b/src/_data/analytics.js @@ -1,23 +1,18 @@ import EleventyFetch from '@11ty/eleventy-fetch' export default async function () { - const API_KEY_NETLIFY = process.env.API_KEY_NETLIFY - const SITE_ID = process.env.SITE_ID - const endDate = new Date(); - const startDate = new Date(new Date().setDate(endDate.getDate() - 30)); - const timezoneOffset = new Date().getTimezoneOffset() / 60; + const API_KEY_FATHOM = process.env.API_KEY_FATHOM const url = - `https://analytics.services.netlify.com/v2/${SITE_ID}/ranking/pages?from=${startDate.getTime()}&to=${endDate.getTime()}&timezone=-0${timezoneOffset}00&limit=50` + 'https://api.usefathom.com/v1/aggregations?entity=pageview&entity_id=CWSVCDJC&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_NETLIFY}`, + Authorization: `Bearer ${API_KEY_FATHOM}`, }, }, }).catch() - const responseObject = await res - const pages = responseObject['data'] - return pages.filter((p) => p.resource.includes('posts')) -} + const pages = await res + return pages.filter((p) => p.pathname.includes('posts')) +} \ No newline at end of file diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index 6e1e2ed1..e35dcd37 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -15,6 +15,7 @@ {% render "../assets/styles/index.css" %} {% endcapture %} + diff --git a/src/_includes/partials/addon-links.liquid b/src/_includes/partials/addon-links.liquid index 26a70e0a..466804dd 100644 --- a/src/_includes/partials/addon-links.liquid +++ b/src/_includes/partials/addon-links.liquid @@ -3,6 +3,10 @@ {% endcapture %}
You can download an OPML file containing all of these feeds and import them into your RSS reader.
+You can download an OPML file containing all of these feeds and import them into your RSS reader.