qiskit.org/nuxt.config.ts

106 lines
2.8 KiB
TypeScript

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.",
);
}
}