@@ -132,6 +132,7 @@ <h1 class="page-title">Source: scripts/generate-sitemap.js</h1>
132132// Configuration
133133const BASE_URL = 'https://riksdagsmonitor.com';
134134const NEWS_DIR = path.join(__dirname, '..', 'news');
135+ const API_DIR = path.join(__dirname, '..', 'api');
135136const ROOT_DIR = path.join(__dirname, '..');
136137const SITEMAP_FILE = path.join(ROOT_DIR, 'sitemap.xml');
137138
@@ -158,8 +159,8 @@ <h1 class="page-title">Source: scripts/generate-sitemap.js</h1>
158159 const articles = new Map();
159160
160161 files.forEach(file => {
161- // Extract base slug and language
162- const match = file.match(/^(.+?)-(en|sv)\.html$/);
162+ // Extract base slug and language (support all 14 languages)
163+ const match = file.match(/^(.+?)-(en|sv|da|no|fi|de|fr|es|nl|ar|he|ja|ko|zh )\.html$/);
163164 if (match) {
164165 const [, baseSlug, lang] = match;
165166 const filePath = path.join(NEWS_DIR, file);
@@ -186,6 +187,29 @@ <h1 class="page-title">Source: scripts/generate-sitemap.js</h1>
186187 return Array.from(articles.values());
187188}
188189
190+ /**
191+ * Get API documentation files
192+ */
193+ function getApiDocs() {
194+ console.log('📚 Scanning API documentation directory...');
195+
196+ if (!fs.existsSync(API_DIR)) {
197+ console.warn('⚠️ API directory not found');
198+ return [];
199+ }
200+
201+ const files = fs.readdirSync(API_DIR)
202+ .filter(file => file.endsWith('.html'));
203+
204+ console.log(` Found ${files.length} API documentation files`);
205+
206+ return files.map(file => ({
207+ file,
208+ path: path.join(API_DIR, file),
209+ lastmod: getFileModTime(path.join(API_DIR, file))
210+ }));
211+ }
212+
189213/**
190214 * Get file modification time
191215 */
@@ -254,17 +278,28 @@ <h1 class="page-title">Source: scripts/generate-sitemap.js</h1>
254278 const politicianDashboardMtime = getFileModTime(path.join(ROOT_DIR, 'politician-dashboard.html'));
255279 xml += generateUrlEntry('politician-dashboard.html', politicianDashboardMtime, 'weekly', '0.8');
256280
257- // Dashboard pages with language alternates
258- const dashboardAlternates = [
259- { lang: 'en', href: 'dashboard/index.html' },
260- { lang: 'sv', href: 'dashboard/index_sv.html' }
261- ];
281+ // Dashboard pages with all language alternates (only for existing files)
282+ const dashboardAlternates = LANGUAGES
283+ .map(lang => ({
284+ lang,
285+ href: lang === 'en' ? 'dashboard/index.html' : `dashboard/index_${lang}.html`
286+ }))
287+ .filter(alt => fs.existsSync(path.join(ROOT_DIR, alt.href)));
262288
289+ // English dashboard (canonical)
263290 const dashboardEnMtime = getFileModTime(path.join(ROOT_DIR, 'dashboard', 'index.html'));
264291 xml += generateUrlEntry('dashboard/index.html', dashboardEnMtime, 'weekly', '0.8', dashboardAlternates);
265292
266- const dashboardSvMtime = getFileModTime(path.join(ROOT_DIR, 'dashboard', 'index_sv.html'));
267- xml += generateUrlEntry('dashboard/index_sv.html', dashboardSvMtime, 'weekly', '0.8');
293+ // All other language dashboard pages
294+ LANGUAGES.filter(lang => lang !== 'en').forEach(lang => {
295+ const loc = `dashboard/index_${lang}.html`;
296+ const dashboardPath = path.join(ROOT_DIR, 'dashboard', `index_${lang}.html`);
297+ if (fs.existsSync(dashboardPath)) {
298+ const lastmod = getFileModTime(dashboardPath);
299+ const priority = lang === 'sv' ? '0.8' : '0.7';
300+ xml += generateUrlEntry(loc, lastmod, 'weekly', priority);
301+ }
302+ });
268303
269304 // Sitemap HTML pages with language alternates
270305 const sitemapAlternates = [
@@ -393,6 +428,19 @@ <h1 class="page-title">Source: scripts/generate-sitemap.js</h1>
393428 });
394429 });
395430
431+ // API Documentation (JSDoc generated)
432+ const apiDocs = getApiDocs();
433+ if (apiDocs.length > 0) {
434+ console.log(` Processing ${apiDocs.length} API documentation files...`);
435+
436+ apiDocs.forEach(doc => {
437+ const loc = `api/${doc.file}`;
438+ // API docs have lower priority but are useful for developers
439+ const priority = doc.file === 'index.html' ? '0.7' : '0.5';
440+ xml += generateUrlEntry(loc, doc.lastmod, 'weekly', priority);
441+ });
442+ }
443+
396444 xml += `
397445
398446</urlset> `;
0 commit comments