|
|
@@ -1,5 +1,5 @@
|
|
1
|
|
-const convertTitleCase = (type) => {
|
|
2
|
|
- if(typeof type !== 'string') return ''
|
|
|
1
|
+const convertTitleCase = type => {
|
|
|
2
|
+ if (typeof type !== 'string') return ''
|
|
3
|
3
|
return type.charAt(0).toUpperCase() + type.slice(1)
|
|
4
|
4
|
}
|
|
5
|
5
|
|
|
|
@@ -37,29 +37,36 @@ const postTypes = [
|
|
37
|
37
|
const typeFromRoute = route => {
|
|
38
|
38
|
let type = route.params.type ? route.params.type : route.fullPath.split('/')
|
|
39
|
39
|
|
|
40
|
|
- if(!route.params.type) {
|
|
|
40
|
+ if (!route.params.type) {
|
|
41
|
41
|
// Remove blank path sections and match to postTypes array
|
|
42
|
42
|
type = type
|
|
43
|
43
|
.filter(pathSection => pathSection != '')
|
|
44
|
44
|
.filter(pathSection => postTypes.includes(pathSection))
|
|
45
|
|
-
|
|
|
45
|
+
|
|
46
|
46
|
// Only take the first match
|
|
47
|
47
|
type = type[0]
|
|
48
|
48
|
console.log(`type derived from route.path: ${type}`)
|
|
49
|
49
|
}
|
|
50
|
|
-
|
|
|
50
|
+
|
|
51
|
51
|
return type
|
|
52
|
52
|
}
|
|
53
|
53
|
|
|
54
|
|
-const ytThumbnail = (url, desiredSize) =>{
|
|
|
54
|
+const ytThumbnail = (url, desiredSize) => {
|
|
55
|
55
|
const remove = [
|
|
56
|
56
|
'',
|
|
57
|
57
|
'https:',
|
|
58
|
58
|
'http:',
|
|
59
|
|
- 'youtu.be'
|
|
|
59
|
+ 'youtu.be',
|
|
|
60
|
+ 'www.youtube.com',
|
|
|
61
|
+ 'youtube.com',
|
|
|
62
|
+ 'embed'
|
|
60
|
63
|
]
|
|
61
|
|
- const videoId = url.split('/').filter(urlSection => !remove.includes(urlSection))
|
|
62
|
|
-
|
|
|
64
|
+ const videoId = url
|
|
|
65
|
+ .split('/')
|
|
|
66
|
+ .filter(urlSection => !remove.includes(urlSection))
|
|
|
67
|
+
|
|
|
68
|
+ // Uncomment to see what the url transformer is finding
|
|
|
69
|
+ // console.log('video:', videoId[0])
|
|
63
|
70
|
let size = '0'
|
|
64
|
71
|
switch (desiredSize) {
|
|
65
|
72
|
case 'medium':
|
|
|
@@ -78,4 +85,11 @@ const ytThumbnail = (url, desiredSize) =>{
|
|
78
|
85
|
return `https://img.youtube.com/vi/${videoId[0]}/${size}.jpg`
|
|
79
|
86
|
}
|
|
80
|
87
|
|
|
81
|
|
-export { convertTitleCase, dePluralize, typeFromRoute, sortTypes, postTypes, ytThumbnail }
|
|
|
88
|
+export {
|
|
|
89
|
+ convertTitleCase,
|
|
|
90
|
+ dePluralize,
|
|
|
91
|
+ typeFromRoute,
|
|
|
92
|
+ sortTypes,
|
|
|
93
|
+ postTypes,
|
|
|
94
|
+ ytThumbnail,
|
|
|
95
|
+}
|