-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.js
204 lines (185 loc) · 6.36 KB
/
nuxt.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
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
import axios from 'axios'
import { sortRoutes } from '@nuxt/utils'
export default {
// Target: https://go.nuxtjs.dev/config-target
target: 'static',
router: {
linkActiveClass: 'active',
extendRoutes(routes, resolve) {
routes.push(
{
path: '/articles/p/:p',
component: resolve(__dirname, 'pages/articles/index.vue'),
name: 'article',
},
{
path: '/articles/category/:categoryId/:p?',
component: resolve(__dirname, 'pages/articles/index.vue'),
name: 'category',
},
{
path: '/articles/series/:seriesId/:p?',
component: resolve(__dirname, 'pages/articles/index.vue'),
name: 'series',
}
)
sortRoutes(routes)
},
},
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'OUCRC | 岡山大学電子計算機研究会',
htmlAttrs: {
lang: 'ja',
},
titleTemplate: '%s - OUCRC | 岡山大学電子計算機研究会',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content:
'岡山大学電子計算機研究会は、パソコンを使ってプログラミングやDTMをしたり、電子工作や3Dプリンターなど "モノづくり" をしている部活です!部にはVRゴーグルやタブレットなどの機材があり、デバッグなども気軽にできます!また、電子工作のパーツや3Dプリンターなどもあるため、ハードルなく "モノづくり" の世界に入ることができます!そして、息抜きにはゲーム大会を開いたり、漫画を読むこともできます。岡大に入学して部活動・サークル選びに迷っている方は、ぜひ一度遊びに来てください!',
},
{
name: 'google-site-verification',
content: 'gUJca8xJ_QAdQ02BNBQRL7jCS53EgM8BWQZqA7zbSQU',
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'apple-touch-icon',
size: '180x180',
href: '/apple-touch-icon.png',
},
/* Google Fonts */
{ rel: 'preconnect', href: 'https://fonts.gstatic.com' },
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&family=Roboto:wght@400;700&display=swap',
},
],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: ['@/assets/css/index.scss'],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
{ src: '~plugins/day.js' },
{ src: '~plugins/lazyload.js' },
{ src: '~plugins/content-parser.server.js' },
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/tailwindcss
'@nuxtjs/tailwindcss',
['@nuxtjs/google-fonts', { display: 'block', download: true, inject: true }],
'@nuxtjs/google-gtag',
'cookie-universal-nuxt',
],
// Google Analytics
'google-gtag': {
id: 'G-7KXW9F58WD',
dev: false,
},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
/**
* パース系ライブラリはESMなので、そのままではdevサーバーで使用できない
* スタンドアロンモードではサーバーサイドのバンドルに含めてしまう
* generate後の動作は問題ない
*/
standalone: true,
},
generate: {
async routes() {
const limit = 9
const headers = {
'X-MICROCMS-API-KEY': process.env.MICROCMS_API_KEY,
}
const range = function* (start, end) {
while (start < end) {
yield start++
}
}
const articleArray = await axios
.get(process.env.API_URL + '/article', {
headers,
params: {
limit: 1000,
fields: 'id,category.id,series.id',
depth: 0,
},
})
.then(({ data }) =>
data.contents.map((v) => {
return [v.id, v.category?.id, v.series?.id]
})
)
const categoryArray = await axios
.get(process.env.API_URL + '/category', {
headers,
params: {
limit: 100,
fields: 'id',
},
})
.then(({ data }) => data.contents.map((content) => content.id))
const seriesArray = await axios
.get(process.env.API_URL + '/series', {
headers,
params: {
limit: 100,
fields: 'id',
},
})
.then(({ data }) => data.contents.map((content) => content.id))
const countArticlesByCategory = Object.fromEntries(categoryArray.map((id) => [id, 0]))
const countArticlesBySeries = Object.fromEntries(seriesArray.map((id) => [id, 0]))
articleArray.forEach(([_, category, series]) => {
if (category in countArticlesByCategory) {
countArticlesByCategory[category]++
}
if (series in countArticlesBySeries) {
countArticlesBySeries[series]++
}
})
return [
...categoryArray.map((key) => ({ route: `/articles/category/${key}` })),
...seriesArray.map((key) => ({ route: `/articles/series/${key}` })),
...[...range(0, Math.ceil(articleArray.length / limit))].map((i) => ({
route: `/articles/p/${i + 1}`,
})),
...Object.entries(countArticlesByCategory)
.map(([k, v]) => {
return [...range(0, Math.ceil(v / limit))].map((i) => ({
route: `/articles/category/${k}/${i + 1}`,
}))
})
.flat(),
...Object.entries(countArticlesBySeries)
.map(([k, v]) => {
return [...range(0, Math.ceil(v / limit))].map((i) => ({
route: `/articles/series/${k}/${i + 1}`,
}))
})
.flat(),
]
},
},
tailwindcss: {
cssPath: '~/assets/css/tailwind.css',
configPath: 'tailwind.config.js',
exposeConfig: false,
config: {},
},
publicRuntimeConfig: {
API_URL: process.env.API_URL,
MICROCMS_API_KEY: process.env.MICROCMS_API_KEY,
},
}