Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
}
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) : {}
}
}