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 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 4x 4x 56x 56x 56x 4x 4x | /**
* @module generate-news-indexes/template/hreflang
* @description Standalone hreflang block generator. Kept as a public export
* for backward compatibility with existing tests; the canonical hreflang
* block is now emitted by `buildChrome`.
*
* @author Hack23 AB
* @license Apache-2.0
*/
import { LANGUAGES } from '../constants.js';
import type { LanguageConfig } from '../types.js';
/** Generate hreflang tags for every supported language plus x-default. */
export function generateHreflangTags(): string {
const tags: string[] = [];
for (const langKey of Object.keys(LANGUAGES)) {
const filename = langKey === 'en' ? 'index.html' : `index_${langKey === 'no' ? 'no' : langKey}.html`;
const hrefLang = (LANGUAGES as Record<string, LanguageConfig>)[langKey]!.code;
tags.push(` <link rel="alternate" hreflang="${hrefLang}" href="https://riksdagsmonitor.com/news/${filename}">`);
}
tags.push(` <link rel="alternate" hreflang="x-default" href="https://riksdagsmonitor.com/news/index.html">`);
return tags.join('\n');
}
|