UNPKG

@gouvfr/dsfr-roller

Version:

Le module `dsfr-roller` permet de publier le site de documentation du Système de Design de l’État - DSFR

25 lines (19 loc) 499 B
import { Node } from './node.js'; import { adjustHeading } from './generic/heading-node.js'; const gather = (node) => { const nodes = node.children.map(child => gather(child)).flat(); nodes.push(node); return nodes; } class NodeRoot extends Node { constructor (data) { super(data); this._nodes = gather(this); adjustHeading(this._nodes.filter(node => node.type === 'heading')); } get nodes () { return this._nodes; } } NodeRoot.TYPE = 'root'; export { NodeRoot };