NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. const convertTitleCase = type => {
  2. if (typeof type !== 'string') return ''
  3. return type.charAt(0).toUpperCase() + type.slice(1)
  4. }
  5. const materials = ['clay', 'fiber', 'glass', 'metal', 'paper', 'wood']
  6. const sortTypes = {
  7. alpha: 'by-alpha',
  8. material: 'by-material',
  9. artist: 'by-artist',
  10. episode: 'by-episode',
  11. upcoming: 'by-upcoming',
  12. current: 'by-current',
  13. subtype: 'by-type',
  14. date: 'by-date',
  15. currentAndUpcoming: 'by-current-and-upcoming',
  16. past: 'by-past',
  17. }
  18. /**
  19. * A list of custom post types used to dispatch vuex actions
  20. * This makes ALL post type modules available for the
  21. * list and single components to request data
  22. */
  23. const postTypes = [
  24. 'sticky',
  25. 'episode',
  26. 'artist',
  27. 'exhibition',
  28. 'event',
  29. 'post',
  30. 'page',
  31. 'short',
  32. 'guide',
  33. 'object',
  34. 'publication',
  35. 'technique',
  36. ]
  37. const ytThumbnail = (url, desiredSize) => {
  38. const remove = [
  39. '',
  40. 'https:',
  41. 'http:',
  42. 'youtu.be',
  43. 'www.youtube.com',
  44. 'youtube.com',
  45. 'embed',
  46. ]
  47. const videoId = url
  48. .split('/')
  49. .filter(urlSection => !remove.includes(urlSection))
  50. // Uncomment to see what the url transformer is finding
  51. // console.log('video:', videoId[0])
  52. let size = 'maxresdefault'
  53. switch (desiredSize) {
  54. case 'medium':
  55. size = 'mqdefault'
  56. break
  57. case 'large':
  58. size = 'hqdefault'
  59. break
  60. case 'standard':
  61. size = 'sddefault'
  62. break
  63. case 'max':
  64. size = 'maxresdefault'
  65. break
  66. }
  67. return `https://img.youtube.com/vi/${videoId[0]}/${size}.jpg`
  68. }
  69. const formatDate = (unix, includeTime) => {
  70. const d = new Date(parseInt(unix) * 1000)
  71. return includeTime
  72. ? d.toLocaleString('en-US', { timeZone: 'UTC' })
  73. : d.toLocaleDateString('en-US', { timeZone: 'UTC' })
  74. }
  75. export {
  76. convertTitleCase,
  77. materials,
  78. sortTypes,
  79. postTypes,
  80. ytThumbnail,
  81. formatDate,
  82. }