File size: 546 Bytes
bc20498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 * Do a shallow merge (first level) of the config object
 * @param {Array<import('types').SSRNode | undefined>} nodes
 */
export function get_page_config(nodes) {
	/** @type {any} */
	let current = {};

	for (const node of nodes) {
		if (!node?.universal?.config && !node?.server?.config) continue;

		current = {
			...current,
			...node?.universal?.config,
			...node?.server?.config
		};
	}

	// TODO 3.0 always return `current`? then we can get rid of `?? {}` in other places
	return Object.keys(current).length ? current : undefined;
}