/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';
const macroReplacer = require( '../../../src/tasks/macro-replacer' );

/*
Umberto issue: #697
*/
hexo.extend.filter.register( 'before_post_render', page => {
	const variables = {};
	if ( page.projectName ) {
		Object.assign( variables, hexo.projectGlobals[ page.projectName ].config.variables );
	}
	Object.assign( variables, hexo.projectGlobals.common.variables );
	page.content = macroReplacer( { fullText: page.content, variables, pagePath: page.source } );
} );
