diff --git a/config/collections/index.js b/config/collections/index.js index 72d8030c..a8610e5d 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -7,7 +7,8 @@ export const searchIndex = (collection) => { let id = 0 const collectionData = collection.getAll()[0] const { data } = collectionData - const { collections: { posts, links } } = data + const { collections: { posts, links }, movies } = data + const movieData = movies.movies.filter(movie => (movie.review?.length && movie.review?.length > 0 && movie.rating)) const addItemToIndex = (items, icon, getUrl, getTitle, getTags) => { if (items) { items.forEach((item) => { @@ -15,7 +16,7 @@ export const searchIndex = (collection) => { id, url: getUrl(item), title: `${icon}: ${getTitle(item)}`, - tags: getTags(item), + tags: getTags ? getTags(item) : [], }) id++ }) @@ -24,6 +25,7 @@ export const searchIndex = (collection) => { addItemToIndex(posts, '📝', item => item.url.includes('http') ? item.url : `https://coryd.dev${item.url}`, item => item.data.title, item => item.data.tags.filter(tag => tag !== 'posts')) addItemToIndex(links, '🔗', item => item.data.link, item => item.data.title, item => item.data.tags) + if (movieData) addItemToIndex(movieData, '🎥', item => item.url, item => `${item.title} (${item.rating})`) return searchIndex } diff --git a/package-lock.json b/package-lock.json index af705ed9..12f5620a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "17.0.5", + "version": "17.1.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "17.0.5", + "version": "17.1.5", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.2.2", @@ -3346,9 +3346,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.782", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.782.tgz", - "integrity": "sha512-JUfU61e8tr+i5Y1FKXcKs+Xe+rJ+CEqm4cgv1kMihPE2EvYHmYyVr3Im/+1+Z5B29Be2EEGCZCwAc6Tazdl1Yg==", + "version": "1.4.783", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.783.tgz", + "integrity": "sha512-bT0jEz/Xz1fahQpbZ1D7LgmPYZ3iHVY39NcWWro1+hA2IvjiPeaXtfSqrQ+nXjApMvQRE2ASt1itSLRrebHMRQ==", "dev": true }, "node_modules/encodeurl": { diff --git a/package.json b/package.json index f69d4f50..621ce28d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "17.0.5", + "version": "17.1.5", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/artists.js b/src/_data/artists.js index 02f9f673..237b1a23 100644 --- a/src/_data/artists.js +++ b/src/_data/artists.js @@ -1,25 +1,10 @@ import { createClient } from '@supabase/supabase-js' +import { parseCountryField } from './utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL || 'YOUR_SUPABASE_URL' const SUPABASE_KEY = process.env.SUPABASE_KEY || 'YOUR_SUPABASE_KEY' const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) -const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) -const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim() - -const parseCountryField = (countryField) => { - if (!countryField) return null - - const delimiters = [',', '/', '&', 'and'] - let countries = [countryField] - - delimiters.forEach(delimiter => { - countries = countries.flatMap(country => country.split(delimiter)) - }) - - return countries.map(getCountryName).join(', ') -} - const PAGE_SIZE = 50 const fetchPaginatedData = async (table, selectFields) => { diff --git a/src/_data/music.js b/src/_data/music.js index b1016587..42e288d9 100644 --- a/src/_data/music.js +++ b/src/_data/music.js @@ -1,36 +1,11 @@ import { createClient } from '@supabase/supabase-js' import { DateTime } from 'luxon' -import slugify from 'slugify' +import { sanitizeMediaString, parseCountryField } from './utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL const SUPABASE_KEY = process.env.SUPABASE_KEY const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) -const sanitizeMediaString = (str) => { - const sanitizedString = str.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '') - - return slugify(sanitizedString, { - replacement: '-', - remove: /[#,&,+()$~%.'":*?<>{}]/g, - lower: true, - }) -} - -const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) -const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim() -const parseCountryField = (countryField) => { - if (!countryField) return null - - const delimiters = [',', '/', '&', 'and'] - let countries = [countryField] - - delimiters.forEach(delimiter => { - countries = countries.flatMap(country => country.split(delimiter)) - }) - - return countries.map(getCountryName).join(', ') -} - const fetchDataForPeriod = async (startPeriod, fields, table) => { const PAGE_SIZE = 1000 let rows = [] diff --git a/src/_data/utilities/index.js b/src/_data/utilities/index.js new file mode 100644 index 00000000..3af71282 --- /dev/null +++ b/src/_data/utilities/index.js @@ -0,0 +1,28 @@ +import slugify from 'slugify' + +export const sanitizeMediaString = (str) => { + const sanitizedString = str.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '') + + return slugify(sanitizedString, { + replacement: '-', + remove: /[#,&,+()$~%.'":*?<>{}]/g, + lower: true, + }) +} + +export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) + +export const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim() + +export const parseCountryField = (countryField) => { + if (!countryField) return null + + const delimiters = [',', '/', '&', 'and'] + let countries = [countryField] + + delimiters.forEach(delimiter => { + countries = countries.flatMap(country => country.split(delimiter)) + }) + + return countries.map(getCountryName).join(', ') +} \ No newline at end of file