-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
83 lines (67 loc) · 2.39 KB
/
.eleventy.js
File metadata and controls
83 lines (67 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Sorts an array of objects, either from collection tags or global data
* @param {number} a first param from sort
* @param {number} b second param from sort
* @returns mutated collection array
*/
const sortCollection = (a, b) => {
if ('data' in a && 'data' in b) {
return Math.sign(a.data.order - b.data.order)
}
return Math.sign(a.order - b.order)
}
const formatDate = (dateString) => {
const dateObj = new Date(dateString)
const month = dateObj.toLocaleString('en-US', { month: 'long' })
const year = dateObj.getFullYear()
return `${month}, ${year}`
}
module.exports = (eleventyConfig) => {
eleventyConfig.addCollection('experienceSection', collectionApi => {
return collectionApi.getFilteredByTag('experience').sort(sortCollection)
})
/**
* Global data being added as collections
*/
eleventyConfig.addCollection('cloudCollection', collectionApi => {
return collectionApi.items[0].data.cloud.sort(sortCollection)
})
eleventyConfig.addCollection('databasesCollection', collectionApi => {
return collectionApi.items[0].data.databases.sort(sortCollection)
})
eleventyConfig.addCollection('frameworksCollection', collectionApi => {
return collectionApi.items[0].data.frameworks.sort(sortCollection)
})
eleventyConfig.addCollection('languageCollection', collectionApi => {
return collectionApi.items[0].data.languages.sort(sortCollection)
})
eleventyConfig.addCollection('projectsCollection', collectionApi => {
return collectionApi.items[0].data.projects.sort(sortCollection)
})
eleventyConfig.addCollection('skillsSection', collectionApi => {
return collectionApi.items[0].data.skills.sort(sortCollection)
})
eleventyConfig.addCollection('toolsCollection', collectionApi => {
return collectionApi.items[0].data.tools.sort(sortCollection)
})
eleventyConfig.addPassthroughCopy({ 'assets': 'images' })
eleventyConfig.addFilter('getJobItemProp', experience => {
return experience.data?.endDate ? 'alumniOf' : 'worksFor'
})
eleventyConfig.addFilter('startDateShortCode', date => {
return formatDate(date)
})
eleventyConfig.addFilter('endDateShortCode', date => {
return date ? formatDate(date) : 'Present'
})
eleventyConfig.addFilter('normalizeFilename', term => {
return term.replace(/\s+/g, '')
})
return {
dir: {
includes: '_partials',
input: 'src',
output: '.cache',
},
}
}