const convertTitleCase = type => { if (typeof type !== 'string') return '' return type.charAt(0).toUpperCase() + type.slice(1) } const materials = ['clay', 'fiber', 'glass', 'metal', 'paper', 'wood'] const sortTypes = { alpha: 'by-alpha', material: 'by-material', artist: 'by-artist', episode: 'by-episode', upcoming: 'by-upcoming', current: 'by-current', subtype: 'by-type', date: 'by-date', currentAndUpcoming: 'by-current-and-upcoming', past: 'by-past', } /** * A list of custom post types used to dispatch vuex actions * This makes ALL post type modules available for the * list and single components to request data */ const postTypes = [ 'sticky', 'episode', 'artist', 'exhibition', 'event', 'post', 'page', 'short', 'guide', 'object', 'publication', 'technique', ] const ytThumbnail = (url, desiredSize) => { const remove = [ '', 'https:', 'http:', 'youtu.be', 'www.youtube.com', 'youtube.com', 'embed', ] const videoId = url .split('/') .filter(urlSection => !remove.includes(urlSection)) // Uncomment to see what the url transformer is finding // console.log('video:', videoId[0]) let size = 'maxresdefault' switch (desiredSize) { case 'medium': size = 'mqdefault' break case 'large': size = 'hqdefault' break case 'standard': size = 'sddefault' break case 'max': size = 'maxresdefault' break } return `https://img.youtube.com/vi/${videoId[0]}/${size}.jpg` } const formatDate = (unix, includeTime) => { const d = new Date(parseInt(unix) * 1000) return includeTime ? d.toLocaleString('en-US', { timeZone: 'UTC' }) : d.toLocaleDateString('en-US', { timeZone: 'UTC' }) } export { convertTitleCase, materials, sortTypes, postTypes, ytThumbnail, formatDate, }