-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move docs node generation to a local plugin (#3113)
* Move docs node generation to a local plugin * Use pluginOptionsSchema API for defaults * Remove unused import
- Loading branch information
1 parent
d1469c5
commit aab010e
Showing
9 changed files
with
100 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const path = require('path') | ||
|
||
const defaultGetTemplate = (template, defaultTemplate) => | ||
template | ||
? require.resolve(path.resolve('src', 'templates', template + '.tsx')) | ||
: defaultTemplate | ||
|
||
exports.pluginOptionsSchema = ({ Joi }) => { | ||
return Joi.object({ | ||
disable: Joi.boolean().default(Boolean(process.env.SKIP_DOCS)), | ||
getTemplate: Joi.function().default(() => defaultGetTemplate), | ||
defaultTemplate: Joi.string().default( | ||
path.resolve('src', 'templates', 'doc.tsx') | ||
) | ||
}) | ||
} | ||
|
||
exports.createSchemaCustomization = async api => { | ||
const { | ||
actions: { createTypes }, | ||
schema: { buildObjectType } | ||
} = api | ||
createTypes([ | ||
buildObjectType({ | ||
name: 'DocsPage', | ||
interfaces: ['Node'], | ||
fields: { | ||
template: 'String', | ||
title: 'String', | ||
description: 'String' | ||
} | ||
}) | ||
]) | ||
} | ||
|
||
exports.createPages = require('./createPages.js') | ||
|
||
exports.onCreateNode = require('./onCreateNode.js') |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "gatsby-theme-iterative-docs", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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