How to use the gatsby-source-filesystem/gatsby-node.sourceNodes function in gatsby-source-filesystem

To help you get started, we’ve selected a few gatsby-source-filesystem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Financial-Times / x-dash / tools / x-docs / plugins / gatsby-plugin-packages / gatsby-node.js View on Github external
const readmePath = path.resolve(packageFullPath, 'readme.md');
		const docsPath = path.resolve(packageFullPath, 'docs');
		const basePath = packagePath.split(path.sep).shift();

		// load the package manifest
		const manifest = require(manifestPath);

		// check if the source files exist
		const [ hasReadme, hasDocs ] = await Promise.all([
			fs.pathExists(readmePath),
			fs.pathExists(docsPath)
		]);

		// pull all of the files into Gatsby
		await Promise.all([
			filesystem.sourceNodes(props, {
				name: `package-${packagePath}`,
				path: manifestPath
			}),
			hasReadme && filesystem.sourceNodes(props, {
				name: `package-${packagePath}`,
				path: readmePath
			}),
			hasDocs && filesystem.sourceNodes(props, {
				name: `package-${packagePath}`,
				path: docsPath
			})
		]);

		// HACK: attempt to pull in any stories from workbench for this package
		const { stories } = components.find((component) => {
			return component.package.name === manifest.name;
github Financial-Times / x-dash / tools / x-docs / plugins / gatsby-plugin-packages / gatsby-node.js View on Github external
// load the package manifest
		const manifest = require(manifestPath);

		// check if the source files exist
		const [ hasReadme, hasDocs ] = await Promise.all([
			fs.pathExists(readmePath),
			fs.pathExists(docsPath)
		]);

		// pull all of the files into Gatsby
		await Promise.all([
			filesystem.sourceNodes(props, {
				name: `package-${packagePath}`,
				path: manifestPath
			}),
			hasReadme && filesystem.sourceNodes(props, {
				name: `package-${packagePath}`,
				path: readmePath
			}),
			hasDocs && filesystem.sourceNodes(props, {
				name: `package-${packagePath}`,
				path: docsPath
			})
		]);

		// HACK: attempt to pull in any stories from workbench for this package
		const { stories } = components.find((component) => {
			return component.package.name === manifest.name;
		}) || {};

		// HACK: if the component has stories then remove references used for hot-reloading
		if (stories) {

gatsby-source-filesystem

Gatsby source plugin for building websites from local data. Markdown, JSON, images, YAML, CSV, and dozens of other data types supported.

MIT
Latest version published 2 months ago

Package Health Score

98 / 100
Full package analysis