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

'use strict';

const executeAndInsertFunctionResults = require( '../../utils/execute-and-insert-function-results' );

/**
 * Replaces the `{@exec path/to/function.js}` expression with the module results.
 *
 * The "path/to/function.js" path must be a relative path to the location where the project configuration (`umberto.json`) is saved.
 *
 * The callback must return a value that will replace the `{@exec ...}` expression.
 * It will be processed by Hexo when building the documentation.
 *
 * Asynchronous functions are not supported by Hexo, so the callback must be synchronous.
 *
 * Make sure it's executed before prerendering of gloria components.
 */
hexo.extend.filter.register( 'before_post_render', page => {
	return executeAndInsertFunctionResults( page, hexo );
}, 6 );
