@@ -72,31 +72,29 @@ export function buildLanguageDisplayNameMap() {
7272 * @returns {string } JavaScript source code string with named exports
7373 */
7474export default function createConfigSource ( input ) {
75- const {
76- version : versionMeta ,
77- changelog,
78- editURL : editURLTemplate ,
79- pageURL : pageURLTemplate ,
80- ...rest
81- } = getConfig ( 'web' ) ;
75+ const config = getConfig ( 'web' ) ;
8276
83- const version = `v${ versionMeta . version } ` ;
84- const editURL = populate ( editURLTemplate , { ...rest , version } ) ;
85- const pageURL = populate ( pageURLTemplate , rest ) ;
77+ const version = `v${ config . version . version } ` ;
78+ const editURL = populate ( config . editURL , { ...config , version } ) ;
79+ const pageURL = populate ( config . pageURL , config ) ;
8680
87- const lines = [ ] ;
81+ const exports = {
82+ ...Object . fromEntries (
83+ Object . entries ( config ) . filter (
84+ ( [ , v ] ) => v === null || typeof v !== 'object'
85+ )
86+ ) ,
87+ version,
88+ versions : buildVersionEntries ( config . changelog , pageURL ) ,
89+ editURL,
90+ pages : buildPageList ( input ) ,
91+ } ;
8892
89- for ( const [ k , v ] of Object . entries ( rest ) ) {
90- if ( v === null || typeof v !== 'object' ) {
91- lines . push ( `export const ${ k } = ${ JSON . stringify ( v ) } ;` ) ;
92- }
93- }
93+ const lines = Object . entries ( exports ) . map (
94+ ( [ k , v ] ) => `export const ${ k } = ${ JSON . stringify ( v ) } ;`
95+ ) ;
9496
9597 lines . push (
96- `export const version = ${ JSON . stringify ( version ) } ;` ,
97- `export const versions = ${ JSON . stringify ( buildVersionEntries ( changelog , pageURL ) ) } ;` ,
98- `export const editURL = ${ JSON . stringify ( editURL ) } ;` ,
99- `export const pages = ${ JSON . stringify ( buildPageList ( input ) ) } ;` ,
10098 `export const languageDisplayNameMap = new Map(${ JSON . stringify ( buildLanguageDisplayNameMap ( ) ) } );`
10199 ) ;
102100
0 commit comments