UNPKG

@gouvfr/dsfr-nexus

Version:

Le module `dsfr-nexus` est l'interface de ligne de commande (CLI) centrale du Système de Design de l’État - DSFR. Il offre des outils pour gérer et compiler les ressources du DSFR

42 lines (34 loc) 995 B
import { CGU_SOURCE, IS_CGU_ACTIVE } from '../../../../../common/constants.js'; import { parseMarkdown, parseFrontMatter } from '../../../../../common/markdown/parse.js'; import { pageNodeFactory } from '../node/page-node-factory.js'; class CGUInterpreter { constructor (state) { this.state = state; } async read () { const response = await fetch(CGU_SOURCE); const content = await response.text(); const nodes = parseMarkdown(content); this._nodes = nodes.map(node => pageNodeFactory(node, this.state)).map(node => node.data); const frontMatter = parseFrontMatter(content); this._version = frontMatter.cguVersion; this._isActive = IS_CGU_ACTIVE; } get nodes () { return this._nodes; } get version () { return this._version; } get isActive () { return this._isActive; } get data () { return { isActive: this.isActive, version: this.version, nodes: this.nodes } } } export { CGUInterpreter };