fix: resolve conflict
This commit is contained in:
parent
7fa65a26da
commit
6a85167ade
9 changed files with 36 additions and 47 deletions
|
@ -1,31 +1,18 @@
|
|||
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&date=last-90-days&output=json`
|
||||
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'
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1h',
|
||||
type: 'json',
|
||||
fetchOptions: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${API_KEY_PLAUSIBLE}`,
|
||||
},
|
||||
},
|
||||
}).catch()
|
||||
const data = await res
|
||||
const pages = data[0].dates[0].items
|
||||
.filter((p) => p.url.includes('posts'))
|
||||
.filter((p) => !p.url.includes('/null'))
|
||||
.map((page) => {
|
||||
return {
|
||||
title: page.title,
|
||||
rank: parseInt(page.value),
|
||||
url: page.url.split('?')[0],
|
||||
}
|
||||
})
|
||||
const postsObj = {}
|
||||
pages.forEach((page) => {
|
||||
if (postsObj[page.url]) {
|
||||
postsObj[page.url].rank += postsObj[page.url].rank
|
||||
} else {
|
||||
postsObj[page.url] = page
|
||||
}
|
||||
})
|
||||
return Object.values(postsObj)
|
||||
const pages = await res
|
||||
return pages.results.filter((p) => p.page.includes('posts')).splice(0, 5)
|
||||
}
|
||||
|
|
Reference in a new issue