parent
e7421c5803
commit
e4ad42cd7f
4 changed files with 27 additions and 27 deletions
|
@ -1,12 +1,12 @@
|
|||
const fetch = require('node-fetch')
|
||||
const { AssetCache } = require('@11ty/eleventy-fetch')
|
||||
const EleventyFetch = require('@11ty/eleventy-fetch')
|
||||
|
||||
module.exports = async function () {
|
||||
const url = 'https://utils.coryd.dev/api/now?endpoints=artists,albums,books,movies,tv'
|
||||
const asset = new AssetCache('now_data')
|
||||
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
|
||||
const now = await fetch(url).then((res) => res.json())
|
||||
await asset.save(now, 'json')
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1h',
|
||||
type: 'json',
|
||||
})
|
||||
const now = await res
|
||||
return {
|
||||
artists: now.artists,
|
||||
albums: now.albums,
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
const fetch = require('node-fetch')
|
||||
const { AssetCache } = require('@11ty/eleventy-fetch')
|
||||
const EleventyFetch = require('@11ty/eleventy-fetch')
|
||||
|
||||
module.exports = async function () {
|
||||
const url = 'https://utils.coryd.dev/api/music?limit=1&period=7day'
|
||||
const asset = new AssetCache('now_playing_data')
|
||||
if (asset.isCacheValid('3m')) return await asset.getCachedValue()
|
||||
const nowPlaying = await fetch(url).then((res) => res.json())
|
||||
await asset.save(nowPlaying, 'json')
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '0s',
|
||||
type: 'json',
|
||||
})
|
||||
const music = await res
|
||||
return {
|
||||
artist: nowPlaying.recenttracks.track[0].artist['#text'],
|
||||
title: nowPlaying.recenttracks.track[0].name,
|
||||
url: nowPlaying.recenttracks.track[0].url,
|
||||
artist: music.recenttracks.track[0].artist['#text'],
|
||||
title: music.recenttracks.track[0].name,
|
||||
url: music.recenttracks.track[0].url,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const fetch = require('node-fetch')
|
||||
const { AssetCache } = require('@11ty/eleventy-fetch')
|
||||
const EleventyFetch = require('@11ty/eleventy-fetch')
|
||||
|
||||
module.exports = async function () {
|
||||
const url = 'https://api.omg.lol/address/cory/statuses/'
|
||||
const asset = new AssetCache('status_data')
|
||||
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
|
||||
const status = await fetch(url).then((res) => res.json())
|
||||
await asset.save(status, 'json')
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1d',
|
||||
type: 'json',
|
||||
})
|
||||
const status = await res
|
||||
return status.response.statuses[0]
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const fetch = require('node-fetch')
|
||||
const { AssetCache } = require('@11ty/eleventy-fetch')
|
||||
const EleventyFetch = require('@11ty/eleventy-fetch')
|
||||
|
||||
module.exports = async function () {
|
||||
const url = 'https://utils.coryd.dev/api/webmentions'
|
||||
const asset = new AssetCache('webmentions_data')
|
||||
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
|
||||
const webmentions = await fetch(url).then((res) => res.json())
|
||||
await asset.save(webmentions, 'json')
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1d',
|
||||
type: 'json',
|
||||
})
|
||||
const webmentions = await res
|
||||
return {
|
||||
mentions: webmentions.children,
|
||||
}
|
||||
|
|
Reference in a new issue