| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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,
- }
|