-
Notifications
You must be signed in to change notification settings - Fork 2
/
scully.StaticAngularBlog.config.ts
103 lines (84 loc) · 2.3 KB
/
scully.StaticAngularBlog.config.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import {
HandledRoute,
registerPlugin,
RouteTypes,
ScullyConfig,
setPluginConfig,
} from '@scullyio/scully';
import '@scullyio/scully-plugin-playwright';
import { Posts } from './src/_assets/posts/posts.json';
import { CodeTips } from './src/_assets/codetips/codetips.json';
import { Pages } from './src/_assets/pages/pages.json';
import { getSitemapPlugin } from '@gammastream/scully-plugin-sitemap';
const SitemapPlugin = getSitemapPlugin();
setPluginConfig(SitemapPlugin, {
urlPrefix: 'https://perko.dev/',
sitemapFilename: 'sitemap.xml',
merge: false,
changeFreq: 'monthly',
routes: {},
});
function blogPostPlugin(): Promise<HandledRoute[]> {
const routes = [];
Posts.forEach((post) => {
routes.push({ route: `/blog/post/${post.link}`, type: RouteTypes.json });
});
return Promise.resolve(routes);
}
registerPlugin('router', 'blogPosts', blogPostPlugin);
function codeTipsPlugin(): Promise<HandledRoute[]> {
const routes = [];
CodeTips.forEach((tip) => {
routes.push({ route: `/code-tips/${tip.link}`, type: RouteTypes.json });
});
return Promise.resolve(routes);
}
registerPlugin('router', 'codeTips', codeTipsPlugin);
function pagesPlugin(): Promise<HandledRoute[]> {
const routes = [];
Pages.forEach((page) => {
routes.push({ route: `/${page.link}`, type: RouteTypes.json });
});
return Promise.resolve(routes);
}
registerPlugin('router', 'pages', pagesPlugin);
function tagsPlugin(): Promise<HandledRoute[]> {
// get all the unique tags
const tags = [];
Posts.forEach((post) => {
if (post.tags) {
post.tags.split(',').forEach((tag) => {
tag = tag.replace(/ /g, '-');
if (tags.indexOf(tag) === -1) {
tags.push(tag);
}
});
}
});
// build the routes
const routes = [];
tags.forEach((tag) => {
routes.push({ route: `/blog/tag/${tag}`, type: RouteTypes.json });
});
return Promise.resolve(routes);
}
registerPlugin('router', 'tags', tagsPlugin);
export const config: ScullyConfig = {
projectRoot: './src',
projectName: 'StaticAngularBlog',
outDir: './dist/static',
routes: {
'/blog/post/:title': {
type: 'blogPosts',
},
'/code-tips/:title': {
type: 'codeTips',
},
'/:page': {
type: 'pages',
},
'/blog/tag/:tag': {
type: 'tags',
},
},
};