1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-26 20:01:24 +01:00

node refactor

This commit is contained in:
Matthias Kretschmann 2018-09-09 21:20:19 +02:00
parent 4fc6639fbd
commit 1e6860d0f1
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -53,31 +53,35 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
fastExif
.read(node.absolutePath)
.then(exifData => {
const iso = exifData.exif.ISO || null
const model = exifData.image.Model || null
const fstop = exifData.exif.FNumber || null
const shutterspeed = exifData.exif.ExposureTime || null
const focalLength = exifData.exif.FocalLength || null
const exposure = exifData.exif.ExposureBiasValue || null
// add exif fields to type File
createNodeField({
node,
name: 'exif',
value: {
iso,
model,
fstop,
shutterspeed,
focalLength,
exposure
}
})
generateExif(exifData, createNodeField, node)
})
.catch(() => null) // just silently fail when exif can't be extracted
}
}
const generateExif = (exifData, createNodeField, node) => {
const iso = exifData.exif.ISO || null
const model = exifData.image.Model || null
const fstop = exifData.exif.FNumber || null
const shutterspeed = exifData.exif.ExposureTime || null
const focalLength = exifData.exif.FocalLength || null
const exposure = exifData.exif.ExposureBiasValue || null
// add exif fields to type File
createNodeField({
node,
name: 'exif',
value: {
iso,
model,
fstop,
shutterspeed,
focalLength,
exposure
}
})
}
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions
@ -115,7 +119,7 @@ exports.createPages = ({ graphql, actions }) => {
generateContent(createPage, posts)
// Generate Tag Pages
createTagPages(createPage, posts)
generateTagPages(createPage, posts)
resolve()
})
@ -149,7 +153,7 @@ const generateContent = (createPage, posts) => {
})
}
const createTagPages = (createPage, posts) => {
const generateTagPages = (createPage, posts) => {
const tagSet = new Set()
const tagMap = new Map()