Skip to content

Commit 84a85bf

Browse files
authored
fix(www): add blogs in sitemap (#18)
1 parent c383e5b commit 84a85bf

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88

99
env:
1010
PNPM_VERSION: 10.4.1
11+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
12+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1113

1214
jobs:
1315
build:

apps/www/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ next-env.d.ts
3232

3333
# remote blog content
3434
/content/blogs/*
35-
/public/blog/*
35+
/public/blog/*
36+
/content/tmp/*

apps/www/scripts/generate-sitemap.mts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ async function generate() {
2424
.filter(page => !page.includes('/_'))
2525
);
2626

27+
// Get blog pages from the build output
28+
const blogPages = await globby(['out/blog/**/*.html'])
29+
.then(pages => pages
30+
.map(page => page
31+
.replace('out', '')
32+
.replace('/index.html', '')
33+
.replace('.html', '')
34+
)
35+
.filter(page => !page.includes('/_') && !page.includes('/blog/index'))
36+
);
37+
2738
const baseUrl = 'https://refref.ai';
2839

2940
const sitemap = `
@@ -72,6 +83,24 @@ async function generate() {
7283
<priority>0.7</priority>
7384
</url>
7485
`),
86+
// Add blog index page
87+
`
88+
<url>
89+
<loc>${baseUrl}/blog</loc>
90+
<lastmod>${new Date().toISOString()}</lastmod>
91+
<changefreq>weekly</changefreq>
92+
<priority>0.8</priority>
93+
</url>
94+
`,
95+
// Add blog pages
96+
...blogPages.map((path) => `
97+
<url>
98+
<loc>${baseUrl}${path}</loc>
99+
<lastmod>${new Date().toISOString()}</lastmod>
100+
<changefreq>weekly</changefreq>
101+
<priority>0.7</priority>
102+
</url>
103+
`),
75104
]
76105
.filter(Boolean)
77106
.join('')}

0 commit comments

Comments
 (0)