All files / utils seo-template.ts

100% Statements 6/6
100% Branches 4/4
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 71x 5x 7x 7x 5x 5x  
export function renderSeoTemplate(template: string, values: Record<string, string | number | undefined | null>) {
    return Object.entries(values).reduce((output, [label, value]) => {
        const val = String(value ?? '');
        return output.replaceAll(`[${label}]`, val).replaceAll(`{${label}}`, val);
    }, String(template || '')).replace(/\s+/g, ' ').trim()
}