forked from stylify/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.ts
executable file
·227 lines (199 loc) · 6.48 KB
/
nuxt.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import { highlightCode } from "./services";
import { BlogRepository } from './services/model/BlogRepository';
import path from 'path';
import fg from 'fast-glob';
import fs from 'fs';
const defaultPageTitle = 'Code your website faster with CSS-like utilities | Stylify CSS';
const defaultPageDescription = 'Stylify CSS uses CSS-like selectors to generate optimized utility-first CSS. Code your website faster. Don\'t study CSS framework. Focus on coding.';
const isProduction = process.env.NODE_ENV === 'production';
const excludedRoutes = [
'/docs/autoprefixer',
'/docs/autoprefixer/',
'/404',
'/404/',
'/docs/profiler',
'/docs/profiler/'
];
const domain = 'https://stylifycss.com';
const defaultOgImage = `${domain}/images/og-image-v2.jpg`;
export default {
server: {
host: '0.0.0.0'
},
target: 'static',
head: {
title: defaultPageTitle,
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ hid: 'description', name: 'description', content: defaultPageDescription },
{ hid: 'robots', name: "robots", content: 'index, follow'},
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'format-detection', content: 'telephone=no' },
{ name: 'msapplication-TileColor', content: '#01befe' },
{ name: 'theme-color', content: '#01befe' },
// Open Graph
{ hid: 'og:title', property: 'og:title', content: defaultPageTitle },
{ hid: 'og:image', property: 'og:image', content: defaultOgImage },
{ hid: 'og:description', property: 'og:description', content: defaultPageDescription },
// Twitter Card
{ hid: 'twitter:image:src', name: 'twitter:image:src', content: defaultOgImage },
{ hid: 'twitter:card', name: 'twitter:card', content: 'summary_large_image' },
{ hid: 'twitter:title', name: 'twitter:title', content: defaultPageTitle },
{ hid: 'twitter:description', name: 'twitter:description', content: defaultPageDescription },
{ hid: 'twitter:site', name: 'twitter:site', content: '@stylifycss' },
],
link: [
{ rel: 'apple-touch-icon', sizes: "180x180", href: '/images/favicon/apple-touch-icon.png?v2' },
{ rel: 'icon', type: "image/png", size: "32x32", href: '/images/favicon/favicon-32x32.png?v2' },
{ rel: 'icon', type: 'image/png', size: "16x16", href: '/images/favicon/favicon-16x16.png?v2' },
{ rel: 'manifest', href: '/site.webmanifest' },
{ rel: 'mask-icon', href: '/images/favicon/safari-pinned-tab.svg', color: "#01befe" },
{ rel: 'shortcut icon', href: "/images/favicon/favicon.ico?v2"},
{ rel: 'preconnect', href: 'https://api.github.com'},
{ rel: 'dns-prefetch', href: 'https://api.github.com'},
{ rel: 'alternate', type: 'application/rss+xml', title: 'Stylify CSS blog posts RSS feed.', href: '/rss/blog.rss'}
],
script: [
{
innerHTML: `{
"@context": "https://schema.org",
"@type": "Organization",
"url": "https://www.example.com",
"logo": "${domain}/images/logo/vertical.png"
}`,
type: 'application/ld+json'
},
{
innerHTML: `{
"@context": "https://schema.org",
"@type": "WebSite",
"url": "${domain}",
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "${domain}/?search={search_term_string}"
},
"query-input": "required name=search_term_string"
}
}`,
type: 'application/ld+json'
},
],
__dangerouslyDisableSanitizers: ['script']
},
css: [
'~/assets/fonts/icons/style.css',
'normalize.css/normalize.css'
],
generate: {
fallback: '404.html',
routes() {
const actualPath = __dirname;
const contentPath = path.join(actualPath, 'content');
let files = fg.sync(path.join(contentPath, 'docs', '**', '*.md'));
return files.map((file) => {
return file.replace(contentPath, '').replace('index.md', '').replace('.md', '');
});
}
},
components: true,
content: {
markdown: {
highlighter(code: string, lang: string) {
return `<pre class="line-numbers language-${lang}"><code>${highlightCode(code, lang)}</code></pre>`;
}
}
},
buildModules: [
'@nuxt/typescript-build',
'@nuxtjs/google-analytics',
'@stylify/nuxt-module'
],
build: {
transpile: [
'@stylify/stylify/lib/index.cjs',
'@stylify/stylify/esm/index.js'
]
},
modules: [
'@nuxt/content',
'@nuxtjs/sitemap'
],
stylelint: {
allowEmptyInput: true
},
hooks: {
'generate:before': async () => {
const { $content } = require("@nuxt/content");
const blogRepository = new BlogRepository($content);
const files = await blogRepository.createQueryBuilder().sortBy("createdAt", "desc")
.only(["path", "annotation", "title"])
.fetch();
const postItems: string[] = [];
files.forEach((file: any) => {
let { path, title, annotation } = file;
path = path.replace(/\/index$/, '');
path = path.replace('\/$', '');
const item = `
<item>
<title>${title}</title>
<link>${domain}/${path}</link>
<guid>${domain}/${path}</guid>
<description>${annotation}</description>
</item>
`.trim();
postItems.push(item);
});
const postsXml = `
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Stylify CSS</title>
<link>${domain}</link>
<atom:link href="${domain}/rss/blog.rss" rel="self" type="application/rss+xml"/>
<description>Stylify is a library that CSS uses CSS-like selectors to generate optimized utility-first CSS. Code your website faster. Don't study CSS framework. Focus on coding.</description>
<image>
<url>${domain}/images/og-image-v2.jpg</url>
<link>${domain}</link>
<title>Stylify CSS</title>
</image>
${postItems.join('\n')}
</channel>
</rss>
`.trim();
fs.writeFileSync('static/rss/blog.rss', postsXml);
}
},
trailingSlash: false,
sitemap: {
hostname: domain,
exclude: excludedRoutes,
routes: async () => {
const { $content } = require("@nuxt/content");
const files = await $content({ deep: true }).only(["path"]).fetch();
const routes = files
.map((file: any) => {
let path = file.path;
path = path.replace(/\/index$/, '');
path = path.replace('\/$', '');
return path;
})
.filter((path: any) => {
return !excludedRoutes.includes(path);
});
return routes;
}
},
plugins: [
'~plugins/index.ts'
],
// gtag("consent","default",{ad_storage:"denied",analytics_storage:"denied"})
googleAnalytics: {
id: isProduction ? 'UA-215428942-1' : null,
storage: 'none'
}
}