This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
/
nuxt.config.ts
105 lines (93 loc) · 2.78 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
import { defineNuxtConfig } from "nuxt/config";
import fetchEvents from "./hooks/update-events";
import fetchAdvocates from "./hooks/update-advocates";
import fetchFallFestEvents from "./hooks/update-fall-fest-events";
import { generateMocks } from "./hooks/mock/mock-service";
const {
AIRTABLE_ACCESS_TOKEN,
GENERATE_CONTENT,
NODE_ENV,
SITE_URL,
MOCK_CONTENT,
} = process.env;
const IS_PRODUCTION = NODE_ENV === "production";
const siteUrl = SITE_URL || "https://qiskit.org";
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
modules: ["@nuxt/content", "@nuxt/image-edge", "nuxt-schema-org"],
schemaOrg: {
host: siteUrl,
},
runtimeConfig: {
public: {
IBM_ANALYTICS_SEGMENT_ANALYTICS_CATEGORY: "",
IBM_ANALYTICS_SEGMENT_INSTANCE_ID: "",
IBM_ANALYTICS_SEGMENT_ANALYTICS_KEY: "",
IBM_ANALYTICS_SEGMENT_ENABLED: IS_PRODUCTION,
IBM_ANALYTICS_SEGMENT_PRODUCT_CODE: "",
IBM_ANALYTICS_SEGMENT_PRODUCT_CODE_TYPE: "",
IBM_ANALYTICS_SEGMENT_PRODUCT_TITLE: "",
IBM_ANALYTICS_SEGMENT_SCRIPT_SRC: "",
IBM_ANALYTICS_SEGMENT_UT30: "",
siteUrl,
},
},
css: ["~/assets/scss/main.scss"],
hooks: {
"build:before": async () => {
if (IS_PRODUCTION || GENERATE_CONTENT) {
await generateContent();
}
},
},
image: {
inject: true,
screens: {
sm: 320,
md: 672,
lg: 1056,
xl: 1312,
xxl: 1584,
},
},
vue: {
compilerOptions: {
isCustomElement: (tag: string) =>
tag.startsWith("qiskit-") || tag.startsWith("bx-"),
},
},
});
/**
* Fetches data from Airtable and generates the advocates and events
* content.
* @returns A promise that resolves when the content has been generated
*/
async function generateContent() {
if (MOCK_CONTENT && MOCK_CONTENT === "true") {
// eslint-disable-next-line no-console
console.info("Mocking content...");
await generateMocks();
// eslint-disable-next-line no-console
console.info("Content generated...");
return;
}
if (AIRTABLE_ACCESS_TOKEN) {
// eslint-disable-next-line no-console
console.info("Generating the events content...");
await fetchEvents(AIRTABLE_ACCESS_TOKEN, "./content/events");
// eslint-disable-next-line no-console
console.info("Generating the fall fest events content...");
await fetchFallFestEvents(
AIRTABLE_ACCESS_TOKEN,
"./content/fall-fest-events",
);
// eslint-disable-next-line no-console
console.info("Generating the advocates content...");
await fetchAdvocates(AIRTABLE_ACCESS_TOKEN, "./content/advocates");
} else {
// eslint-disable-next-line no-console
console.warn(
"No AIRTABLE_ACCESS_TOKEN environment variable found. Skipping content generation.",
);
}
}