Skip to content

Commit bdd1a5e

Browse files
authored
Merge pull request #233 from Hack23/copilot/analyse-sitemap-html-files
Enhance sitemap coverage and workflow automation
2 parents ebc5d81 + 63c316d commit bdd1a5e

7 files changed

Lines changed: 3505 additions & 221 deletions

.github/workflows/deploy-s3.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ jobs:
142142
echo "✅ Deploy with cache headers completed"
143143
144144
# Invalidate CloudFront cache to ensure latest content is served
145+
# Note: Using blanket "/*" invalidation is optimal for this use case:
146+
# - Site has ~500 files (well within 1000 free invalidations/month)
147+
# - Deployment frequency is low (PR-based, not continuous)
148+
# - Simplicity trumps optimization at this scale
149+
# - Cache headers already optimized (1hr HTML, 1yr assets, 24hr metadata)
145150
- name: Invalidate CloudFront
146151
run: |
147152
echo "🔍 Discovering CloudFront distribution ID from stack: ${{ env.CLOUDFRONT_STACK_NAME }}"

.github/workflows/jsdoc-validation.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,38 @@ jobs:
5858
npm run jsdoc
5959
echo "✅ JSDoc generation complete"
6060
61-
- name: Commit API Documentation
61+
- name: Update Sitemap
62+
id: update_sitemap
63+
run: |
64+
echo "🗺️ Updating sitemap.xml with API documentation..."
65+
npm run generate-sitemap
66+
echo "✅ Sitemap updated"
67+
68+
- name: Commit API Documentation and Sitemap
6269
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/copilot/'))
6370
run: |
6471
# Configure git
6572
git config --local user.email "github-actions[bot]@users.noreply.github.com"
6673
git config --local user.name "github-actions[bot]"
6774
6875
# Check if there are changes to commit
69-
git add api/
76+
git add api/ sitemap.xml
7077
7178
if git diff --staged --quiet; then
72-
echo "📝 No changes to API documentation"
79+
echo "📝 No changes to API documentation or sitemap"
7380
else
74-
echo "📝 Committing updated API documentation..."
75-
git commit -m "docs: Update JSDoc API documentation [skip ci]
81+
echo "📝 Committing updated API documentation and sitemap..."
82+
git commit -m "docs: Update JSDoc API documentation and sitemap.xml [skip ci]
7683
7784
- Generated from latest JavaScript source code
85+
- Updated sitemap.xml with API documentation URLs
7886
- Includes intelligence operative perspective
7987
- Deployed via GitHub Pages
8088
8189
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
8290
8391
git push
84-
echo "✅ API documentation committed and pushed"
92+
echo "✅ API documentation and sitemap committed and pushed"
8593
fi
8694
8795
- name: Verify api/ Directory Created

api/module-Sitemap%20Generation%20-%20Multi-Language%20SEO%20Infrastructure.html

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ <h4 class="name" id="~generateSitemap"><span class="type-signature">(inner) </sp
298298

299299
<dt class="tag-source">Source:</dt>
300300
<dd class="tag-source"><ul class="dummy"><li>
301-
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line199">line 199</a>
301+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line223">line 223</a>
302302
</li></ul></dd>
303303

304304

@@ -386,7 +386,95 @@ <h4 class="name" id="~generateUrlEntry"><span class="type-signature">(inner) </s
386386

387387
<dt class="tag-source">Source:</dt>
388388
<dd class="tag-source"><ul class="dummy"><li>
389-
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line176">line 176</a>
389+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line200">line 200</a>
390+
</li></ul></dd>
391+
392+
393+
394+
395+
396+
397+
398+
</dl>
399+
400+
401+
402+
403+
404+
405+
406+
407+
408+
409+
410+
411+
412+
413+
414+
415+
416+
417+
418+
419+
420+
421+
422+
423+
424+
425+
<h4 class="name" id="~getApiDocs"><span class="type-signature">(inner) </span>getApiDocs<span class="signature">()</span><span class="type-signature"></span></h4>
426+
427+
428+
429+
430+
431+
432+
<div class="description">
433+
<p>Get API documentation files</p>
434+
</div>
435+
436+
437+
438+
439+
440+
441+
442+
443+
444+
445+
446+
447+
448+
<dl class="details">
449+
450+
451+
452+
453+
454+
455+
456+
457+
458+
459+
460+
461+
462+
463+
464+
465+
466+
467+
468+
469+
470+
471+
472+
473+
474+
475+
<dt class="tag-source">Source:</dt>
476+
<dd class="tag-source"><ul class="dummy"><li>
477+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line165">line 165</a>
390478
</li></ul></dd>
391479

392480

@@ -474,7 +562,7 @@ <h4 class="name" id="~getFileModTime"><span class="type-signature">(inner) </spa
474562

475563
<dt class="tag-source">Source:</dt>
476564
<dd class="tag-source"><ul class="dummy"><li>
477-
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line164">line 164</a>
565+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line188">line 188</a>
478566
</li></ul></dd>
479567

480568

@@ -562,7 +650,7 @@ <h4 class="name" id="~getNewsArticles"><span class="type-signature">(inner) </sp
562650

563651
<dt class="tag-source">Source:</dt>
564652
<dd class="tag-source"><ul class="dummy"><li>
565-
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line116">line 116</a>
653+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line117">line 117</a>
566654
</li></ul></dd>
567655

568656

@@ -650,7 +738,7 @@ <h4 class="name" id="~main"><span class="type-signature">(inner) </span>main<spa
650738

651739
<dt class="tag-source">Source:</dt>
652740
<dd class="tag-source"><ul class="dummy"><li>
653-
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line410">line 410</a>
741+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line458">line 458</a>
654742
</li></ul></dd>
655743

656744

@@ -738,7 +826,7 @@ <h4 class="name" id="~validateSitemap"><span class="type-signature">(inner) </sp
738826

739827
<dt class="tag-source">Source:</dt>
740828
<dd class="tag-source"><ul class="dummy"><li>
741-
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line378">line 378</a>
829+
<a href="scripts_generate-sitemap.js.html">scripts/generate-sitemap.js</a>, <a href="scripts_generate-sitemap.js.html#line426">line 426</a>
742830
</li></ul></dd>
743831

744832

api/scripts_generate-sitemap.js.html

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ <h1 class="page-title">Source: scripts/generate-sitemap.js</h1>
132132
// Configuration
133133
const BASE_URL = 'https://riksdagsmonitor.com';
134134
const NEWS_DIR = path.join(__dirname, '..', 'news');
135+
const API_DIR = path.join(__dirname, '..', 'api');
135136
const ROOT_DIR = path.join(__dirname, '..');
136137
const 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
&lt;/urlset>`;

0 commit comments

Comments
 (0)