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

'use strict';

/**
 * Sets layout for API pages and the landing page.
 * page.layout indicates the template which should be used to render the page.
 */
hexo.extend.filter.register( 'before_post_render', page => {
	const theme = [ 'ckeditor4', 'ckfinder' ].includes( page.projectName ) ? 'umberto' : 'gloria';

	page.projectTheme = theme;

	if ( page.category === 'api-reference' ) {
		page.layout = theme + '/api';
		page.isApi = true;
	} else if ( page.category === 'sdk' ) {
		page.layout = theme + '/sdk';
		page.isSdk = true;
	} else if ( page.path === 'index.html' ) {
		page.layout = theme + '/index';
	} else {
		page.layout = theme + '/' + page.layout;
	}
}, 3 );
