twerske fbfd4889a9 build(docs-infra): error guides in docs (#40060)
add /errors to docs
create formatting for error guides infra

PR Close #40060
2021-01-14 11:28:52 -08:00

29 lines
896 B
JavaScript

/**
* Split the description (of selected docs) into:
* * `shortDescription`: the first paragraph
* * `description`: the rest of the paragraphs
*/
module.exports = function splitDescription() {
return {
$runAfter: ['tags-extracted'],
$runBefore: ['processing-docs'],
docTypes: [],
$process(docs) {
docs.forEach(doc => {
if (this.docTypes.indexOf(doc.docType) !== -1 && doc.description !== undefined) {
const description = doc.description.trim();
const endOfParagraph = description.search(/\n\s*\n/);
if (endOfParagraph === -1) {
doc.shortDescription = description;
doc.description = '';
} else {
doc.shortDescription = description.substr(0, endOfParagraph).trim();
doc.description = description.substr(endOfParagraph).trim();
}
}
});
}
};
};