1
0
mirror of synced 2025-12-23 21:07:12 -05:00

Hello git history spelunker!

Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
This commit is contained in:
Vanessa Yuen
2020-09-27 14:10:11 +02:00
parent fa8bb2322f
commit 3df90fc9b8
28386 changed files with 1723440 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
const fs = require('fs')
const path = require('path')
const { liquid } = require('../../../lib/render-content')
const getMiniTocItems = require('../../../lib/get-mini-toc-items')
const includes = path.join(process.cwd(), 'includes')
const objectIncludeFile = fs.readFileSync(path.join(includes, 'graphql-object.html'), 'utf8')
// TODO need to localize
const currentLanguage = 'en'
module.exports = async function prerenderObjects (schemaJsonPerVersion) {
const site = await require('../../../lib/site-data')()
// create a bare minimum context for rendering the graphql-object.html layout
const context = {
currentLanguage,
site: site[currentLanguage].site,
graphql: { schemaForCurrentVersion: schemaJsonPerVersion }
}
const objectsArray = []
// render the graphql-object.html layout for every object
for (const object of schemaJsonPerVersion.objects) {
context.item = object
const objectHtml = await liquid.parseAndRender(objectIncludeFile, context)
objectsArray.push(objectHtml)
}
const objectsHtml = objectsArray.join('\n')
return {
html: objectsHtml,
miniToc: getMiniTocItems(objectsHtml)
}
}