feat: eleventy transform for images

This commit is contained in:
Cory Dransfeldt 2024-02-13 15:28:28 -08:00
parent 243b1103e4
commit 7e1597b36a
No known key found for this signature in database
36 changed files with 179 additions and 1262 deletions

View file

@ -1,24 +1,18 @@
import EleventyFetch from '@11ty/eleventy-fetch'
import AnalyticsMock from './json/mocks/analytics.js'
export default async function () {
const API_KEY_PLAUSIBLE = process.env.API_KEY_PLAUSIBLE
const url =
'https://plausible.io/api/v1/stats/breakdown?site_id=coryd.dev&period=6mo&property=event:page&limit=30'
let pages;
if (process.env.ELEVENTY_PRODUCTION) {
const res = EleventyFetch(url, {
duration: '1h',
type: 'json',
fetchOptions: {
headers: {
Authorization: `Bearer ${API_KEY_PLAUSIBLE}`,
},
const res = EleventyFetch(url, {
duration: '1h',
type: 'json',
fetchOptions: {
headers: {
Authorization: `Bearer ${API_KEY_PLAUSIBLE}`,
},
}).catch()
pages = await res
} else {
pages = AnalyticsMock
}
},
}).catch()
const pages = await res
return pages.results.filter((p) => p.page.includes('posts'))
}