add stats to the console output

This commit is contained in:
Hans Pagel 2021-02-26 16:35:53 +01:00
parent 6305e865a7
commit c5d84aa87e

View File

@ -10,6 +10,9 @@ module.exports = function (api) {
cwd: process.cwd(),
})
let numberOfPages = 0
let numberOfDemos = 0
api.loadSource(() => {
/**
* Generate pages for all demo components for testing purposes
@ -28,6 +31,8 @@ module.exports = function (api) {
demos.push(match[1])
})
numberOfDemos = demos.length
api.createPages(({ createPage }) => {
createPage({
path: '/demos',
@ -76,8 +81,16 @@ module.exports = function (api) {
})
api.onCreateNode(options => {
if (process.env.NODE_ENV === 'production' && options.internal.typeName === 'DocPage') {
if (options.internal.typeName === 'DocPage') {
numberOfPages += 1
if (process.env.NODE_ENV === 'production') {
createSpecificOpenGraphImage(options.title, options.content, `static/images${options.path}og-image.png`)
}
}
})
api.configureServer(() => {
console.log(`[STATS] ${numberOfPages} pages, ${numberOfDemos} interactive demos`)
})
}