forked from colinhacks/devii
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemap.ts
49 lines (43 loc) · 1.32 KB
/
sitemap.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
export const sitemap = '';
import glob from 'glob';
import { getStaticPaths as getBlogPaths } from './pages/blog/[blog]';
export const generateSitemap = async () => {
const pagesDir = './pages/**/*.*';
const posts = await glob.sync(pagesDir);
const pagePaths = posts
.filter((path) => !path.includes('['))
.filter((path) => !path.includes('/_'))
.map((path) => path.slice(1));
const blogPaths = await getBlogPaths().paths;
const sitemap = `
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://vriad.com</loc>
<lastmod>2020-06-01</lastmod>
</url>
${[...pagePaths, ...blogPaths].map((path) => {
const item = [`<url>`];
item.push(` <loc>https://vriad.com${path}</loc>`);
item.push(` <lastmod>2020-06-01</lastmod>`);
return [`<url>`];
})}
<url>
<loc>https://vriad.com/essay/zod</loc>
<lastmod>2020-03-28</lastmod>
</url>
<url>
<loc>https://vriad.com/essay/devii</loc>
<lastmod>2020-05-28</lastmod>
</url>
<url>
<loc>https://vriad.com/essay/say-no-to-emotion-core</loc>
<lastmod>2020-06-05</lastmod>
</url>
<url>
<loc>https://vriad.com/essay/css-in-js-is-inevitable</loc>
<lastmod>2020-06-07</lastmod>
</url>
</urlset>`;
return sitemap;
};