mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-30 07:58:11 +01:00
node refactor
This commit is contained in:
parent
4fc6639fbd
commit
1e6860d0f1
@ -53,31 +53,35 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
|
|||||||
fastExif
|
fastExif
|
||||||
.read(node.absolutePath)
|
.read(node.absolutePath)
|
||||||
.then(exifData => {
|
.then(exifData => {
|
||||||
const iso = exifData.exif.ISO || null
|
generateExif(exifData, createNodeField, node)
|
||||||
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
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(() => null) // just silently fail when exif can't be extracted
|
.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 }) => {
|
exports.createPages = ({ graphql, actions }) => {
|
||||||
const { createPage } = actions
|
const { createPage } = actions
|
||||||
|
|
||||||
@ -115,7 +119,7 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
generateContent(createPage, posts)
|
generateContent(createPage, posts)
|
||||||
|
|
||||||
// Generate Tag Pages
|
// Generate Tag Pages
|
||||||
createTagPages(createPage, posts)
|
generateTagPages(createPage, posts)
|
||||||
|
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
@ -149,7 +153,7 @@ const generateContent = (createPage, posts) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const createTagPages = (createPage, posts) => {
|
const generateTagPages = (createPage, posts) => {
|
||||||
const tagSet = new Set()
|
const tagSet = new Set()
|
||||||
const tagMap = new Map()
|
const tagMap = new Map()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user