gatsby#ParentSpanPluginArgs TypeScript Examples
The following examples show how to use
gatsby#ParentSpanPluginArgs.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: on-pre-bootstrap.ts From gatsby-project-kb with MIT License | 5 votes |
onPreBootstrap = async (
{ cache }: ParentSpanPluginArgs,
_options?: PluginOptions
) => {
const options = resolveOptions(_options)
const { contentPath, extensions, ignore } = options
if (!options.contentPath) return
const tree = new ContentTree(
new ContentNode({
name: contentPath,
path: contentPath,
key: contentPath,
})
)
const entries: fsWalk.Entry[] = fsWalk
.walkSync(contentPath, {
basePath: '',
deepFilter: (entry) => {
return !/\/node_modules\//.test(entry.path)
},
entryFilter: (entry) => {
if (ignore) {
return !anymatch(ignore, entry.path)
}
return true
}
})
.filter((entry) => {
if (entry.dirent.isDirectory()) return false
if (!extensions.includes(path.extname(entry.name))) {
return false
}
return true
})
// walk the contentPath and collect all possible files,
// then write the constructed file tree to gatsby cache for further usage in `setFieldsOnGraphQLNodeType` phase
entries.forEach((entry) => {
const node = new ContentNode({
name: entry.name,
path: entry.path,
key: path.basename(entry.name, path.extname(entry.name)),
})
tree.add(node)
})
const repr = tree.serialize()
await cache.set(CONTEXT_TREE_CACHE_KEY, repr)
}
Example #2
Source File: onPreBootstrap.ts From gatsby-plugin-react-i18next with MIT License | 5 votes |
onPreBootstrap = (_args: ParentSpanPluginArgs, pluginOptions: PluginOptions) => {
// Check for deprecated option.
if (pluginOptions.hasOwnProperty('path')) {
console.error(
`gatsby-plugin-react-i18next: "path" option is deprecated. Please remove it from config in your gastby-config.js. As of v1.0.0, language JSON resources should be loaded by gatsby-source-filesystem plugin and then fetched by GraphQL query. It enables incremental build and hot-reload as language JSON files change.\nSee details: https://github.com/microapps/gatsby-plugin-react-i18next`
);
}
}