Update individual snippet pages

Reduce data sizes and load times, improve performance
This commit is contained in:
Angelos Chalaris
2019-09-16 22:43:14 +03:00
parent e4569284eb
commit 31dee63aa3
3 changed files with 35 additions and 59 deletions

View File

@ -188,7 +188,7 @@ exports.createPages = ({ graphql, actions }) => {
const snippets = result.data.allSnippet.edges;
snippets.forEach(snippet => {
if(!snippet.archived) {
if (!snippet.node.archived) {
createPage({
path: `/snippet${snippet.node.slug}`,
component: snippetPage,
@ -210,7 +210,11 @@ exports.createPages = ({ graphql, actions }) => {
});
// Create tag pages.
const tags = [...new Set(snippets.map(snippet => snippet.tags.primary))].sort((a,b) => a.localeCompare(b));
const tags = [...new Set(
snippets.map(snippet => (snippet.tags || {primary: null}).primary)
)]
.filter(Boolean)
.sort((a, b) => a.localeCompare(b));
tags.forEach(tag => {
const tagPath = `/tag/${toKebabCase(tag)}/`;