How to use the react-styleguidist/lib/loaders/utils/slugger.slug function in react-styleguidist

To help you get started, we’ve selected a few react-styleguidist 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 vue-styleguidist / vue-styleguidist / packages / vue-styleguidist / src / loaders / utils / getSections.ts View on Github external
let sectionDepth

	if (parentDepth === undefined) {
		sectionDepth = section.sectionDepth !== undefined ? section.sectionDepth : 0
	} else {
		sectionDepth = parentDepth === 0 ? 0 : parentDepth - 1
	}

	return {
		name: section.name || '',
		exampleMode: section.exampleMode || config.exampleMode,
		usageMode: section.usageMode || config.usageMode,
		sectionDepth,
		description: section.description,
		slug: slugger.slug(section.name || ''),
		sections: getSections(section.sections || [], config, sectionDepth),
		filepath: contentRelativePath,
		href: section.href,
		components: getSectionComponents(section, config),
		content,
		external: section.external
	}
}
github vue-styleguidist / vue-styleguidist / packages / vue-styleguidist / src / loaders / utils / processComponent.ts View on Github external
const componentPath = path.relative(config.configDir || '', filepath)
	const componentName = getNameFromFilePath(filepath)
	const props = requireIt(`!!${vueDocLoader}!${filepath}`)
	const examplesFile = config.getExampleFilename(filepath)
	const componentMetadataPath = getComponentMetadataPath(filepath)
	const hasExamplesFile = examplesFile && fs.existsSync(examplesFile)
	let hasInternalExamples = false
	if (!hasExamplesFile && fs.existsSync(componentPath)) {
		const customBlocks = parseComponent(fs.readFileSync(componentPath, 'utf8')).customBlocks
		hasInternalExamples = !!customBlocks && customBlocks.findIndex(p => p.type === 'docs') >= 0
	}
	const hasExamples = hasExamplesFile || hasInternalExamples

	return {
		filepath: componentPath,
		slug: slugger.slug(componentName),
		pathLine: config.getComponentPathLine(componentPath),
		module: requireIt(filepath),
		props,
		hasExamples,
		metadata: fs.existsSync(componentMetadataPath) ? requireIt(componentMetadataPath) : {}
	}
}