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

25 lines (20 loc) 653 B
import { Redirection } from '@gouvfr/dsfr-roller' import { createFile, readYAMLSync } from '@gouvfr/dsfr-forge'; import fs from 'fs' import yaml from 'yaml' class RedirectionPublisher { constructor (state) { this._state = state; } async read () { const redirectionsData = readYAMLSync(this._state.configFile('redirect.yml')); this._redirections = redirectionsData.map(data => new Redirection(data)); } async write () { for (const redirection of this._redirections) { const html = await redirection.render(); createFile(this._state.destFile(redirection.dest), html); } } } export { RedirectionPublisher };