-
Notifications
You must be signed in to change notification settings - Fork 0
/
next-sitemap.config.js
51 lines (43 loc) · 1.26 KB
/
next-sitemap.config.js
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
50
51
module.exports = {
additionalPaths: async () => {
if (!process.env.GHOST_PRIVATE_KEY || !process.env.NEXT_PUBLIC_GHOST_API)
return [];
const GhostAdminAPI = require("@tryghost/admin-api");
const ghostAdminApi = new GhostAdminAPI({
key: process.env.GHOST_PRIVATE_KEY,
url: process.env.NEXT_PUBLIC_GHOST_API,
version: "v3.0",
});
// The pagination will not be necessary for a while
const getPosts = () =>
ghostAdminApi.posts.browse({
fields: "slug",
filter: "status:published",
limit: 1000,
page: 1,
});
const getTags = () =>
ghostAdminApi.tags.browse({
fields: "slug",
limit: 1000,
});
const [tags, posts] = await Promise.all([getTags(), getPosts()]);
return posts
.map((p) => {
if (!p.slug) return null;
// This is also defined in `src/api/posts/index.ts`
if (p.slug.startsWith("how-to-stake")) return `/staking/${p.slug}`;
return `/blog/${p.slug}`;
})
.concat(tags.map((t) => `/tag/${t.slug}`))
.filter(Boolean)
.map((loc) => ({
loc,
}));
},
autoLastmod: false,
changefreq: null,
generateRobotsTxt: false,
priority: null,
siteUrl: "https://www.forbole.com",
};