diff --git a/.eslintrc.js b/.eslintrc.js index d63928f..02e6421 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,7 @@ module.exports = { env: { node: true, + es6: true, }, extends: ["eslint:recommended", "plugin:prettier/recommended"], parserOptions: { diff --git a/package.json b/package.json index 127f80c..f2242c7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "postcss": "^8.4.33", "postcss-import": "^16.0.0", "postcss-import-ext-glob": "^2.1.1", - "prettier": "3.2.4", - "slugify": "^1.6.6" + "prettier": "3.2.4" } } diff --git a/src/_data/helpers.js b/src/_data/helpers.js deleted file mode 100644 index b5e01a1..0000000 --- a/src/_data/helpers.js +++ /dev/null @@ -1,75 +0,0 @@ -/** © Andy Bell - https://buildexcellentwebsit.es/ */ - -module.exports = { - /** - * Returns back some attributes based on wether the - * link is active or a parent of an active item - * - * @param {String} itemUrl The link in question - * @param {String} pageUrl The page context - * @returns {String} The attributes or empty - */ - getLinkActiveState(itemUrl, pageUrl) { - let response = ""; - - if (itemUrl === pageUrl) { - response = ' aria-current="page"'; - } - - if (itemUrl.length > 1 && pageUrl.indexOf(itemUrl) === 0) { - response += ' data-state="active"'; - } - - return response; - }, - /** - * Filters out the passed item from the passed collection - * and randomises and limits them based on flags - * - * @param {Array} collection The 11ty collection we want to take from - * @param {Object} item The item we want to exclude (often current page) - * @param {Number} limit=3 How many items we want back - * @param {Boolean} random=true Wether or not this should be randomised - * @returns {Array} The resulting collection - */ - getSiblingContent(collection, item, limit = 3, random = true) { - let filteredItems = collection.filter((x) => x.url !== item.url); - - if (random) { - let counter = filteredItems.length; - - while (counter > 0) { - // Pick a random index - let index = Math.floor(Math.random() * counter); - - counter--; - - let temp = filteredItems[counter]; - - // Swap the last element with the random one - filteredItems[counter] = filteredItems[index]; - filteredItems[index] = temp; - } - } - - // Lastly, trim to length - if (limit > 0) { - filteredItems = filteredItems.slice(0, limit); - } - - return filteredItems; - }, - - /** - * Take an array of keys and return back items that match. - * Note: items in the collection must have a key attribute in - * Front Matter - * - * @param {Array} collection 11ty collection - * @param {Array} keys collection of keys - * @returns {Array} result collection or empty - */ - filterCollectionByKeys(collection, keys) { - return collection.filter((x) => keys.includes(x.data.key)); - }, -}; diff --git a/src/_data/lastfm.js b/src/_data/lastfm.js index 39dc6a5..f4c7e03 100644 --- a/src/_data/lastfm.js +++ b/src/_data/lastfm.js @@ -42,7 +42,7 @@ const fetchRecentAlbums = async (period = "7day") => { const fetchRecentTracks = async () => { const url = `http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=wonderfulfrog&api_key=${lastFmApiKey}&format=json`; - const response = await EleventyFetch(url, { duration: "1m", type: "json" }); + const response = await EleventyFetch(url, { duration: "5m", type: "json" }); const tracks = response.recenttracks.track.slice(0, 5); const recentTracks = tracks.map((track) => { diff --git a/src/_data/letterboxd.js b/src/_data/letterboxd.js index c393817..2ee1edc 100644 --- a/src/_data/letterboxd.js +++ b/src/_data/letterboxd.js @@ -12,7 +12,7 @@ dayjs.extend(relativeTime); const fetchRecentMovies = async () => { const url = `https://letterboxd.com/wonderfulfrog/rss/`; - const response = await EleventyFetch(url, { duration: "1m", type: "text" }); + const response = await EleventyFetch(url, { duration: "1d", type: "text" }); const $ = cheerio.load(response, { xml: true });