imfreedom/www.imfreedom.org
Clone
Summary
Browse
Changes
Graph
Mark John as the treasurer, Move Ethan to a director, alphabetize the rest of the list
2019-12-14, Gary Kramlich
120a5e6ac12e
Mark John as the treasurer, Move Ethan to a director, alphabetize the rest of the list
/**
* Creates meetings data for hugo to consume
*
* From:
* * data/meetings.json
* * hugo/content/mintues/*
* * hugo/content/transcripts/*
*/
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
meetingsData
=
require
(
'../data/meetings.json'
)
const
hugoDir
=
path
.
join
(
__dirname
,
'..'
,
'hugo'
)
searchAndAddMeetingsPages
(
'minutes'
)
searchAndAddMeetingsPages
(
'transcripts'
)
/**
* Looks for pages in hugo content and if it exist sets a flag that it exsists
* @param {string} type
*/
function
searchAndAddMeetingsPages
(
type
)
{
const
dir
=
path
.
join
(
hugoDir
,
'content'
,
type
)
fs
.
readdirSync
(
dir
).
map
(
file
=>
{
const
key
=
file
.
replace
(
/\.md$/
,
''
)
if
(
!
meetingsData
[
key
])
{
meetingsData
[
key
]
=
{}
}
meetingsData
[
key
][
type
]
=
true
})
}
// Create an ordered array for hugo to read
const
d
=
Object
.
entries
(
meetingsData
)
.
sort
(([
a
],
[
b
])
=>
b
.
localeCompare
(
a
))
.
map
(([
key
,
{
...
v
}])
=>
({
key
,
...
v
}))
// Write data into hugo data dir
const
targetPath
=
path
.
join
(
hugoDir
,
'data'
,
'meetings.json'
)
fs
.
writeFileSync
(
targetPath
,
JSON
.
stringify
(
d
,
null
,
'\t'
))
console
.
log
(
'done'
)