2020-10-22 21:25:10 +08:00
|
|
|
/// <reference path="types/index.d.ts" />
|
|
|
|
|
2019-06-06 23:12:57 +08:00
|
|
|
import path from 'path'
|
2019-06-20 04:36:42 +08:00
|
|
|
import fs from 'fs'
|
2020-04-08 15:48:46 +08:00
|
|
|
import consola from 'consola'
|
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// TODO: Deletes markdown references. We are not using md as content anymore
|
|
|
|
// import markdownIt from 'markdown-it'
|
|
|
|
// import miLinkAttributes from 'markdown-it-link-attributes'
|
|
|
|
// import miAnchor from 'markdown-it-anchor'
|
|
|
|
// import uslug from 'uslug'
|
|
|
|
// import Mode from 'frontmatter-markdown-loader/mode'
|
2020-01-14 16:04:09 +08:00
|
|
|
|
|
|
|
import pkg from './package.json'
|
2020-04-08 15:48:46 +08:00
|
|
|
import fetchEvents from './hooks/update-events'
|
2020-11-12 19:20:53 +08:00
|
|
|
import fetchAdvocates from './hooks/update-advocates'
|
2022-05-27 21:39:35 +08:00
|
|
|
import fetchEcosystemMembers from './hooks/update-ecosystem'
|
2020-04-08 15:48:46 +08:00
|
|
|
|
2020-10-22 21:25:10 +08:00
|
|
|
const {
|
|
|
|
NODE_ENV,
|
|
|
|
ENABLE_ANALYTICS,
|
|
|
|
GENERATE_CONTENT,
|
|
|
|
AIRTABLE_API_KEY
|
|
|
|
} = process.env
|
2020-04-12 18:58:33 +08:00
|
|
|
|
|
|
|
const IS_PRODUCTION = NODE_ENV === 'production'
|
2019-06-06 14:30:22 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// const md = markdownIt({
|
|
|
|
// linkify: true,
|
|
|
|
// html: true
|
|
|
|
// })
|
2020-10-22 21:25:10 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// md.use(miLinkAttributes, {
|
|
|
|
// pattern: /^https?:/,
|
|
|
|
// attrs: {
|
|
|
|
// target: '_blank',
|
|
|
|
// rel: 'noopener'
|
|
|
|
// }
|
|
|
|
// })
|
2020-10-22 21:25:10 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// md.use(miAnchor, {
|
|
|
|
// slugify (id: any) { return uslug(id) }
|
|
|
|
// })
|
2019-06-19 21:05:16 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
export default defineNuxtConfig({
|
|
|
|
// target: 'static',
|
2021-10-25 21:00:13 +08:00
|
|
|
|
2022-06-09 21:12:03 +08:00
|
|
|
// Disable Server Side rendering
|
|
|
|
ssr: false,
|
|
|
|
|
|
|
|
// Inline server bundle dependencies
|
2023-02-10 20:35:43 +08:00
|
|
|
// standalone: true,
|
|
|
|
|
|
|
|
runtimeConfig: {
|
|
|
|
// Keys within public are also exposed client-side
|
|
|
|
public: {
|
|
|
|
analyticsScriptUrl: IS_PRODUCTION
|
|
|
|
? 'https://cloud.ibm.com/analytics/build/bluemix-analytics.min.js'
|
|
|
|
: 'https://dev.console.test.cloud.ibm.com/analytics/build/bluemix-analytics.min.js',
|
|
|
|
analyticsKey: IS_PRODUCTION
|
|
|
|
? 'ffdYLviQze3kzomaINXNk6NwpY9LlXcw'
|
|
|
|
: 'zbHWEXPUfXm0K6C7HbegwB5ewDEC8o1H',
|
|
|
|
}
|
2021-08-06 23:18:35 +08:00
|
|
|
},
|
|
|
|
|
2019-06-06 14:30:22 +08:00
|
|
|
/*
|
|
|
|
** Headers of the page
|
|
|
|
*/
|
2023-02-10 20:35:43 +08:00
|
|
|
app: {
|
|
|
|
head: {
|
|
|
|
title: pkg.name,
|
|
|
|
meta: [
|
|
|
|
{ charset: 'utf-8' },
|
|
|
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
|
|
{ hid: 'description', name: 'description', content: pkg.description }
|
|
|
|
],
|
|
|
|
link: [
|
|
|
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
|
|
|
]
|
|
|
|
}
|
2019-06-06 14:30:22 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Customize the progress-bar color
|
|
|
|
*/
|
2023-02-10 20:35:43 +08:00
|
|
|
// loading: { color: '#fff' },
|
2019-06-06 14:30:22 +08:00
|
|
|
|
2021-04-20 21:50:56 +08:00
|
|
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
2019-06-06 14:30:22 +08:00
|
|
|
css: [
|
2021-04-20 21:50:56 +08:00
|
|
|
'~/assets/scss/main.scss'
|
2019-06-06 14:30:22 +08:00
|
|
|
],
|
|
|
|
|
|
|
|
/*
|
2020-01-08 19:13:51 +08:00
|
|
|
** Plugins to load before mounting the App.
|
2019-06-06 14:30:22 +08:00
|
|
|
*/
|
|
|
|
plugins: [
|
2023-02-10 20:35:43 +08:00
|
|
|
// '~/plugins/router-hooks.ts',
|
|
|
|
// '~/plugins/carbon.ts',
|
|
|
|
// '~/plugins/deep-load.ts',
|
|
|
|
// { src: '~/plugins/hotjar.ts', mode: 'client' },
|
|
|
|
// ...optional(
|
|
|
|
// IS_PRODUCTION || ENABLE_ANALYTICS,
|
|
|
|
// { src: '~/plugins/segment-analytics.ts', mode: 'client' } as const
|
|
|
|
// )
|
2019-06-06 14:30:22 +08:00
|
|
|
],
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Nuxt.js modules
|
|
|
|
*/
|
|
|
|
modules: [
|
2023-01-21 01:02:02 +08:00
|
|
|
'@nuxt/content'
|
2019-06-06 14:30:22 +08:00
|
|
|
],
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Build configuration
|
|
|
|
*/
|
|
|
|
build: {
|
2019-06-25 04:23:22 +08:00
|
|
|
// TODO: Workaround for dealing with. Remove once its solved:
|
|
|
|
// https://github.com/nuxt/nuxt.js/issues/3877
|
2023-02-10 20:35:43 +08:00
|
|
|
// splitChunks: {
|
|
|
|
// layouts: true
|
|
|
|
// }
|
2019-06-19 21:05:16 +08:00
|
|
|
},
|
|
|
|
|
2019-06-20 04:36:42 +08:00
|
|
|
generate: {
|
2023-02-10 20:35:43 +08:00
|
|
|
// TODO It is preferred to use nitro.prerender.routes
|
|
|
|
// https://nuxt.com/docs/api/configuration/nuxt-config#routes
|
|
|
|
|
|
|
|
//TODO: This is the code for the old events
|
|
|
|
// routes: (function () {
|
|
|
|
// const events = getContentUrls('events')
|
|
|
|
|
|
|
|
// return [...events]
|
|
|
|
|
|
|
|
// function getContentUrls (contentRoot: string): string[] {
|
|
|
|
// return fs.readdirSync(path.resolve(__dirname, 'content', contentRoot))
|
|
|
|
// .filter(isContentAndNotReadme)
|
|
|
|
// .map(toContentUrl(contentRoot))
|
|
|
|
// }
|
|
|
|
|
|
|
|
// function isContentAndNotReadme (filename: string): boolean {
|
|
|
|
// return path.extname(filename) === '.md' &&
|
|
|
|
// path.parse(filename).name.toUpperCase() !== 'README'
|
|
|
|
// }
|
|
|
|
|
|
|
|
// function toContentUrl (contentRoot: string): (s: string) => string {
|
|
|
|
// return (filename: string): string => {
|
|
|
|
// return `/${contentRoot}/${path.parse(filename).name}`
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// })()
|
2019-10-29 16:53:51 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
hooks: {
|
2023-02-10 20:35:43 +08:00
|
|
|
// build: {
|
|
|
|
// async before () {
|
|
|
|
// if (!IS_PRODUCTION && !GENERATE_CONTENT) {
|
|
|
|
// console.warn('Skipping content generation. Set GENERATE_CONTENT to enable it.')
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
// await generateContent()
|
|
|
|
// }
|
|
|
|
// }
|
2019-06-06 14:30:22 +08:00
|
|
|
}
|
2023-02-10 20:35:43 +08:00
|
|
|
})
|
2020-07-03 23:02:19 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// function optional<T> (test: any, ...plugins: T[]): T[] {
|
|
|
|
// return test ? plugins : []
|
|
|
|
// }
|
2020-11-12 19:20:53 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// async function generateContent () {
|
|
|
|
// if (AIRTABLE_API_KEY) {
|
|
|
|
// consola.info('Generating community event previews')
|
|
|
|
// await fetchEvents(AIRTABLE_API_KEY, './content/events')
|
2022-05-27 21:39:35 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// consola.info('Generating advocate previews')
|
|
|
|
// await fetchAdvocates(AIRTABLE_API_KEY, './content/advocates')
|
|
|
|
// } else {
|
|
|
|
// consola.warn('Cannot generate events: missing AIRTABLE_API_KEY environment variable')
|
|
|
|
// }
|
2020-04-08 15:48:46 +08:00
|
|
|
|
2023-02-10 20:35:43 +08:00
|
|
|
// await fetchEcosystemMembers('./content/ecosystem')
|
|
|
|
// }
|