Created
February 12, 2018 18:46
-
-
Save dmachat/1e712ff1c3e0cd15ca7014c80dd9e885 to your computer and use it in GitHub Desktop.
segment data by timeframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timeframes = [ | |
{ | |
name: '1900-1920', | |
range: [timestamp, timestamp] // you could also parse this from the name | |
slug: 'timeframes/1900-1920', | |
}, | |
... | |
]; | |
function filterDataByTimeframe(range, data) { | |
return data.filter(item => { | |
// logic to determine whether item is within range | |
}); | |
} | |
timeframes.forEach(timeframe => { | |
const filteredData = filterDataByTimeframe(timeframe.range, results.data.allMarkdownRemark.edges); | |
createPaginatedPages({ | |
pathPrefix: timeframe.slug, | |
edges: filteredData, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment