You've already forked AstralRinth
forked from didirus/AstralRinth
* feat: start on tax compliance * feat: avarala1099 composable * fix: shouldShow should be managed on the page itself * refactor: move show logic to revenue page * feat: security practices rather than info * feat: withdraw page lock * fix: empty modal bug & lint issues * feat: hide behind feature flag * Use standard admonition components, make casing consistent * modal title * lint * feat: withdrawal check * feat: tax cap on withdrawals warning * feat: start on revenue page overhaul * feat: segment generation for bar * feat: tooltips and links * fix: tooltip border * feat: finish initial layout, start on withdraw modal * feat: start on withdrawal limit stage * feat: shade support for primary colors * feat: start on withdraw details stage * fix: convert swatches to hex * feat: payout method/region dropdown temporarily using multiselect * feat: fix modal open issues and use teleport dropdowns * feat: hide transactions section if there are no transactions * refactor: NavStack surfaces * feat: new dropdown component * feat: remove teleport dropdown modal in favour of new combobox component * fix: lint * refactor: dashboard sidebar layout * feat: cleanup * fix: niche bugs * fix: ComboBox styling * feat: first part of qa * feat: animate flash rather than tooltip * fix: lint * feat: qa border gradient * fix: seg hover flashes * feat: i18n * feat: i18n and final QA * fix: lint * feat: QA * fix: lint * fix: merge conflicts * fix: intl * fix: blue hover * fix: transfers page * feat: surface variables & gradients * feat: text vars * fix: lint * fix: intl * feat: stages * fix: lint * feat: region selection * feat: method selection btns * fix: flex col on transactions * feat: hook up method selection to ctx * feat: muralpay kyc stage info * wip: muralpay integration * Basic Mural Pay API bindings * Fix clippy * use dotenvy in muralpay example * Refactor payout creation code * wip: muralpay payout requests * Mural Pay payouts work * Fix clippy * feat: progress * fix: broken tax form stage logic * polish: tax form stage and method selection stage layout * add mural pay fees API * Work on payout fee API * Fees API for more payment methods * Fix CI * polish: muralpay qa * refactor: clean up combobox component * polish: change from critical -> warning admonition in MuralpayDetailsStage * Temporarily disable Venmo and PayPal methods from frontend * polish: clean up transaction component & page * polish: navbar qa, text color-contrast in chips type buttonstyled, mb on rev/index.vue page * fix: incorrectly using available balance as tax form withdraw limit after tax forms submitted * wip: counterparties * Start on counterparties and payment methods API * polish: combobox component * polish: fix broken scroll logic using a composable & web:fix * fix: lint * polish: various QA fixes * feat: hook up with backend (wip) * feat: draft muralpay rails dynamic logic * polish: modify rails to support backend changes * Mural Pay multiple methods when fetching * Don't send supported_countries to frontend * Mural Pay multiple methods when fetching * Don't send supported_countries to frontend * feat: fees & methods endpoint hookup * chore: remove duplicates fix * polish: qa changes + figma match * Add countries to muralpay fiat methods * Compile fix * Add exchange rate info to fees endpoint * Add fees to premium Tremendous options * polish: i18n and better document type dropdown -> id input labels * feat: tremendous * fix: lint & i18n * feat: reintroduce tin mismatch logic to index.vue * polish: qa * fix: i18n * feat: remove teleport dropdown menu - combobox should be used * fix: lint * fix: jsdoc * feat: checkbox for reward program terms * Add delivery email field to Tremendous payouts * Add Tremendous product category to payout methods * Add bank details API to muralpay * Fix CI * Fix CI * polish: qa changes * feat: i18n pass * feat: deduplicate methods endpoint & fix i18n issues * chore: deduplicate i18n strings into common-messages.ts * fix: lint * fix: i18n * feat: estimates * polish: more QA * Remove prepaid visa, compute fees properly for Tremendous methods * Add more details to Tremendous errors * feat: withdraw endpoint impl & internals refactor * Add more details to Tremendous errors * feat: completion stage * Add fees to Mural * feat: transactions page match figma * fix: i18n * polish: QA changes * polish: qa * Payout history route and bank details * polish: autofill and requirements checks * fix: i18n + lint * fix: fiat rail fees * polish: move scroll fade stuff into NewModal rather than just CreatorWithdrawModal * feat: simplify action btn logic & tax form error * fix: tax -> Tax form * Re-add legacy PayPal/Venmo options for US * feat: mobile responsiveness fixes for modal * fix: responsiveness issues * feat: navstack responsiveness * fix: responsiveness * move the mural bank details route * fix: generated state cleanup & bank details input * fix: lint & i18n * Add utoipa support to payout endpoints * address some PR comments * polish: qa * add CORS to new utoipa routes * feat: legacy paypal/venmo stage * polish: reset amount on back qa * revert: navstack mr changes * polish: loading indicator on method selection stage * fix: paypal modal doesnt reopen after auth * fix: lint & i18n * fix: paypal flow * polish: qa changes * fix: gitignore * polish: qa fixes * fix: payouts_available in payouts.rs * fix: bug when limit is zero * polish: qa changes * fix: qa stuff & muralpay sub-division fix * Immediately approve mural payouts * Add currency support to Tremendous payouts * Currency forex * add forex to tremendous fee request * polish: qa & currency support for paypal tremendous * polish: fx qa * feat: demo mode flag * fix: i18n & padding issues * polish: qa changes * fix: ml * Add Mural balance to bank balance info * polish: show warning for paypal international USD withdrawals + more currencies * Add more Tremendous currencies support * fix: colors on balance bars * fix: empty states * fix: pl-8 mobile issue * fix: hide see all * Transaction payouts available use the correct date * Address my own review comment * Address PR comments * Change Mural withdrawal limit to 3k * fix: empty state + paypal warning * maybe fix tremendous gift cards * Change how Mural minimum withdrawals are calculated * Tweak min/max withdrawal values * fix: segment brightness * fix: min & max for muralpay & legacy paypal * Fix some icon issues * more issues * fix user menu * fix: remove + network --------- Signed-off-by: Calum H. <contact@cal.engineer> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: aecsocket <aecsocket@tutanota.com> Co-authored-by: Alejandro González <me@alegon.dev>
592 lines
16 KiB
TypeScript
592 lines
16 KiB
TypeScript
import { pathToFileURL } from 'node:url'
|
|
|
|
import { match as matchLocale } from '@formatjs/intl-localematcher'
|
|
import serverSidedVue from '@vitejs/plugin-vue'
|
|
import { consola } from 'consola'
|
|
import { promises as fs } from 'fs'
|
|
import { globIterate } from 'glob'
|
|
import { defineNuxtConfig } from 'nuxt/config'
|
|
import { $fetch } from 'ofetch'
|
|
import Papa from 'papaparse'
|
|
import { basename, relative, resolve } from 'pathe'
|
|
import svgLoader from 'vite-svg-loader'
|
|
|
|
import type { GeneratedState } from './src/composables/generated'
|
|
|
|
const STAGING_API_URL = 'https://staging-api.modrinth.com/v2/'
|
|
// ISO 3166 data from https://github.com/ipregistry/iso3166
|
|
// Licensed under CC BY-SA 4.0
|
|
const ISO3166_REPO = 'https://raw.githubusercontent.com/ipregistry/iso3166/master'
|
|
|
|
const preloadedFonts = [
|
|
'inter/Inter-Regular.woff2',
|
|
'inter/Inter-Medium.woff2',
|
|
'inter/Inter-SemiBold.woff2',
|
|
'inter/Inter-Bold.woff2',
|
|
]
|
|
|
|
const favicons = {
|
|
'(prefers-color-scheme:no-preference)': '/favicon-light.ico',
|
|
'(prefers-color-scheme:light)': '/favicon-light.ico',
|
|
'(prefers-color-scheme:dark)': '/favicon.ico',
|
|
}
|
|
|
|
/**
|
|
* Tags of locales that are auto-discovered besides the default locale.
|
|
*
|
|
* Preferably only the locales that reach a certain threshold of complete
|
|
* translations would be included in this array.
|
|
*/
|
|
const enabledLocales: string[] = []
|
|
|
|
/**
|
|
* Overrides for the categories of the certain locales.
|
|
*/
|
|
const localesCategoriesOverrides: Partial<Record<string, 'fun' | 'experimental'>> = {
|
|
'en-x-pirate': 'fun',
|
|
'en-x-updown': 'fun',
|
|
'en-x-lolcat': 'fun',
|
|
'en-x-uwu': 'fun',
|
|
'ru-x-bandit': 'fun',
|
|
ar: 'experimental',
|
|
he: 'experimental',
|
|
pes: 'experimental',
|
|
}
|
|
|
|
export default defineNuxtConfig({
|
|
srcDir: 'src/',
|
|
app: {
|
|
head: {
|
|
htmlAttrs: {
|
|
lang: 'en',
|
|
},
|
|
title: 'Modrinth',
|
|
link: [
|
|
// The type is necessary because the linter can't always compare this very nested/complex type on itself
|
|
...preloadedFonts.map((font): object => {
|
|
return {
|
|
rel: 'preload',
|
|
href: `https://cdn-raw.modrinth.com/fonts/${font}?v=3.19`,
|
|
as: 'font',
|
|
type: 'font/woff2',
|
|
crossorigin: 'anonymous',
|
|
}
|
|
}),
|
|
...Object.entries(favicons).map(([media, href]): object => {
|
|
return { rel: 'icon', type: 'image/x-icon', href, media }
|
|
}),
|
|
...Object.entries(favicons).map(([media, href]): object => {
|
|
return { rel: 'apple-touch-icon', type: 'image/x-icon', href, media, sizes: '64x64' }
|
|
}),
|
|
{
|
|
rel: 'search',
|
|
type: 'application/opensearchdescription+xml',
|
|
href: '/opensearch.xml',
|
|
title: 'Modrinth mods',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
vite: {
|
|
define: {
|
|
global: {},
|
|
},
|
|
esbuild: {
|
|
define: {
|
|
global: 'globalThis',
|
|
},
|
|
},
|
|
cacheDir: '../../node_modules/.vite/apps/knossos',
|
|
resolve: {
|
|
dedupe: ['vue'],
|
|
},
|
|
plugins: [
|
|
svgLoader({
|
|
svgoConfig: {
|
|
plugins: [
|
|
{
|
|
name: 'preset-default',
|
|
params: {
|
|
overrides: {
|
|
removeViewBox: false,
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
},
|
|
hooks: {
|
|
async 'nitro:config'(nitroConfig) {
|
|
const emailTemplates = Object.keys(
|
|
await import('./src/templates/emails/index.ts').then((m) => m.default),
|
|
)
|
|
const docTemplates = Object.keys(
|
|
await import('./src/templates/docs/index.ts').then((m) => m.default),
|
|
)
|
|
|
|
nitroConfig.prerender = nitroConfig.prerender || {}
|
|
nitroConfig.prerender.routes = nitroConfig.prerender.routes || []
|
|
for (const template of emailTemplates) {
|
|
nitroConfig.prerender.routes.push(`/_internal/templates/email/${template}`)
|
|
}
|
|
for (const template of docTemplates) {
|
|
nitroConfig.prerender.routes.push(`/_internal/templates/doc/${template}`)
|
|
}
|
|
},
|
|
async 'build:before'() {
|
|
// 30 minutes
|
|
const TTL = 30 * 60 * 1000
|
|
|
|
let state: Partial<GeneratedState> = {}
|
|
|
|
try {
|
|
state = JSON.parse(await fs.readFile('./src/generated/state.json', 'utf8'))
|
|
} catch {
|
|
// File doesn't exist, create folder
|
|
await fs.mkdir('./src/generated', { recursive: true })
|
|
}
|
|
|
|
const API_URL = getApiUrl()
|
|
|
|
if (
|
|
// Skip regeneration if within TTL...
|
|
state.lastGenerated &&
|
|
new Date(state.lastGenerated).getTime() + TTL > new Date().getTime() &&
|
|
// ...but only if the API URL is the same
|
|
state.apiUrl === API_URL &&
|
|
// ...and if no errors were caught during the last generation
|
|
(state.errors ?? []).length === 0
|
|
) {
|
|
console.log(
|
|
'Tags already recently generated. Delete apps/frontend/generated/state.json to force regeneration.',
|
|
)
|
|
return
|
|
}
|
|
|
|
state.lastGenerated = new Date().toISOString()
|
|
|
|
state.apiUrl = API_URL
|
|
|
|
const headers = {
|
|
headers: {
|
|
'user-agent': 'Knossos generator (support@modrinth.com)',
|
|
},
|
|
}
|
|
|
|
const caughtErrorCodes = new Set<number>()
|
|
|
|
function handleFetchError(err: any, defaultValue: any) {
|
|
console.error('Error generating state: ', err)
|
|
caughtErrorCodes.add(err.status)
|
|
return defaultValue
|
|
}
|
|
|
|
const [
|
|
categories,
|
|
loaders,
|
|
gameVersions,
|
|
donationPlatforms,
|
|
reportTypes,
|
|
homePageProjects,
|
|
homePageSearch,
|
|
homePageNotifs,
|
|
products,
|
|
muralBankDetails,
|
|
countriesCSV,
|
|
subdivisionsCSV,
|
|
] = await Promise.all([
|
|
$fetch(`${API_URL}tag/category`, headers).catch((err) => handleFetchError(err, [])),
|
|
$fetch(`${API_URL}tag/loader`, headers).catch((err) => handleFetchError(err, [])),
|
|
$fetch(`${API_URL}tag/game_version`, headers).catch((err) => handleFetchError(err, [])),
|
|
$fetch(`${API_URL}tag/donation_platform`, headers).catch((err) =>
|
|
handleFetchError(err, []),
|
|
),
|
|
$fetch(`${API_URL}tag/report_type`, headers).catch((err) => handleFetchError(err, [])),
|
|
$fetch(`${API_URL}projects_random?count=60`, headers).catch((err) =>
|
|
handleFetchError(err, []),
|
|
),
|
|
$fetch(`${API_URL}search?limit=3&query=leave&index=relevance`, headers).catch((err) =>
|
|
handleFetchError(err, {}),
|
|
),
|
|
$fetch(`${API_URL}search?limit=3&query=&index=updated`, headers).catch((err) =>
|
|
handleFetchError(err, {}),
|
|
),
|
|
$fetch(`${API_URL.replace('/v2/', '/_internal/')}billing/products`, headers).catch((err) =>
|
|
handleFetchError(err, []),
|
|
),
|
|
$fetch(`${API_URL.replace('/v2/', '/_internal/')}mural/bank-details`, headers).catch(
|
|
(err) => handleFetchError(err, null),
|
|
),
|
|
$fetch<string>(`${ISO3166_REPO}/countries.csv`, {
|
|
...headers,
|
|
responseType: 'text',
|
|
}).catch((err) => handleFetchError(err, '')),
|
|
$fetch<string>(`${ISO3166_REPO}/subdivisions.csv`, {
|
|
...headers,
|
|
responseType: 'text',
|
|
}).catch((err) => handleFetchError(err, '')),
|
|
])
|
|
|
|
const countriesData = Papa.parse(countriesCSV, {
|
|
header: true,
|
|
skipEmptyLines: true,
|
|
transformHeader: (header) => (header.startsWith('#') ? header.slice(1) : header),
|
|
}).data
|
|
const subdivisionsData = Papa.parse(subdivisionsCSV, {
|
|
header: true,
|
|
skipEmptyLines: true,
|
|
transformHeader: (header) => (header.startsWith('#') ? header.slice(1) : header),
|
|
}).data
|
|
|
|
const subdivisionsByCountry = (subdivisionsData as any[]).reduce(
|
|
(acc, sub) => {
|
|
const countryCode = sub.country_code_alpha2
|
|
|
|
if (!countryCode || typeof countryCode !== 'string' || countryCode.trim() === '') {
|
|
return acc
|
|
}
|
|
|
|
if (!acc[countryCode]) acc[countryCode] = []
|
|
|
|
acc[countryCode].push({
|
|
code: sub['subdivision_code_iso3166-2'],
|
|
name: sub.subdivision_name,
|
|
localVariant: sub.localVariant || null,
|
|
category: sub.category,
|
|
parent: sub.parent_subdivision || null,
|
|
language: sub.language_code,
|
|
})
|
|
return acc
|
|
},
|
|
{} as Record<string, any[]>,
|
|
)
|
|
|
|
state.categories = categories
|
|
state.loaders = loaders
|
|
state.gameVersions = gameVersions
|
|
state.donationPlatforms = donationPlatforms
|
|
state.reportTypes = reportTypes
|
|
state.homePageProjects = homePageProjects
|
|
state.homePageSearch = homePageSearch
|
|
state.homePageNotifs = homePageNotifs
|
|
state.products = products
|
|
state.muralBankDetails = muralBankDetails.bankDetails
|
|
state.countries = (countriesData as any[]).map((c) => ({
|
|
alpha2: c.country_code_alpha2,
|
|
alpha3: c.country_code_alpha3,
|
|
numeric: c.numeric_code,
|
|
nameShort: c.name_short,
|
|
nameLong: c.name_long,
|
|
}))
|
|
state.subdivisions = subdivisionsByCountry
|
|
state.errors = [...caughtErrorCodes]
|
|
|
|
await fs.writeFile('./src/generated/state.json', JSON.stringify(state))
|
|
|
|
console.log('Tags generated!')
|
|
},
|
|
'pages:extend'(routes) {
|
|
routes.splice(
|
|
routes.findIndex((x) => x.name === 'search-searchProjectType'),
|
|
1,
|
|
)
|
|
|
|
const types = ['mods', 'modpacks', 'plugins', 'resourcepacks', 'shaders', 'datapacks']
|
|
|
|
types.forEach((type) =>
|
|
routes.push({
|
|
name: `search-${type}`,
|
|
path: `/${type}`,
|
|
file: resolve(__dirname, 'src/pages/search/[searchProjectType].vue'),
|
|
children: [],
|
|
}),
|
|
)
|
|
},
|
|
async 'vintl:extendOptions'(opts) {
|
|
opts.locales ??= []
|
|
|
|
const isProduction = getDomain() === 'https://modrinth.com'
|
|
|
|
const resolveCompactNumberDataImport = await (async () => {
|
|
const compactNumberLocales: string[] = []
|
|
|
|
for await (const localeFile of globIterate(
|
|
'node_modules/@vintl/compact-number/dist/locale-data/*.mjs',
|
|
{ ignore: '**/*.data.mjs' },
|
|
)) {
|
|
const tag = basename(localeFile, '.mjs')
|
|
compactNumberLocales.push(tag)
|
|
}
|
|
|
|
function resolveImport(tag: string) {
|
|
const matchedTag = matchLocale([tag], compactNumberLocales, 'en-x-placeholder')
|
|
return matchedTag === 'en-x-placeholder'
|
|
? undefined
|
|
: `@vintl/compact-number/locale-data/${matchedTag}`
|
|
}
|
|
|
|
return resolveImport
|
|
})()
|
|
|
|
const resolveOmorphiaLocaleImport = await (async () => {
|
|
const omorphiaLocales: string[] = []
|
|
const omorphiaLocaleSets = new Map<string, { files: { from: string; format?: string }[] }>()
|
|
|
|
for (const pkgLocales of [`node_modules/@modrinth/**/src/locales/*`]) {
|
|
for await (const localeDir of globIterate(pkgLocales, {
|
|
posix: true,
|
|
})) {
|
|
const tag = basename(localeDir)
|
|
if (!omorphiaLocales.includes(tag)) {
|
|
omorphiaLocales.push(tag)
|
|
}
|
|
|
|
const entry = omorphiaLocaleSets.get(tag) ?? { files: [] }
|
|
omorphiaLocaleSets.set(tag, entry)
|
|
|
|
for await (const localeFile of globIterate(`${localeDir}/*`, { posix: true })) {
|
|
entry.files.push({
|
|
from: pathToFileURL(localeFile).toString(),
|
|
format: 'default',
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
return function resolveLocaleImport(tag: string) {
|
|
return omorphiaLocaleSets.get(matchLocale([tag], omorphiaLocales, 'en-x-placeholder'))
|
|
}
|
|
})()
|
|
|
|
for await (const localeDir of globIterate('src/locales/*/', { posix: true })) {
|
|
const tag = basename(localeDir)
|
|
if (isProduction && !enabledLocales.includes(tag) && opts.defaultLocale !== tag) continue
|
|
|
|
const locale =
|
|
opts.locales.find((locale) => locale.tag === tag) ??
|
|
opts.locales[opts.locales.push({ tag }) - 1]!
|
|
|
|
const localeFiles = (locale.files ??= [])
|
|
|
|
for await (const localeFile of globIterate(`${localeDir}/*`, { posix: true })) {
|
|
const fileName = basename(localeFile)
|
|
if (fileName === 'index.json') {
|
|
localeFiles.push({
|
|
from: `./${relative('./src', localeFile)}`,
|
|
format: 'crowdin',
|
|
})
|
|
} else if (fileName === 'meta.json') {
|
|
const meta: Record<string, { message: string }> = await fs
|
|
.readFile(localeFile, 'utf8')
|
|
.then((date) => JSON.parse(date))
|
|
const localeMeta = (locale.meta ??= {})
|
|
for (const key in meta) {
|
|
const value = meta[key]
|
|
if (value === undefined) continue
|
|
localeMeta[key] = value.message
|
|
}
|
|
} else {
|
|
;(locale.resources ??= {})[fileName] = `./${relative('./src', localeFile)}`
|
|
}
|
|
}
|
|
|
|
const categoryOverride = localesCategoriesOverrides[tag]
|
|
if (categoryOverride != null) {
|
|
;(locale.meta ??= {}).category = categoryOverride
|
|
}
|
|
|
|
const omorphiaLocaleData = resolveOmorphiaLocaleImport(tag)
|
|
if (omorphiaLocaleData != null) {
|
|
localeFiles.push(...omorphiaLocaleData.files)
|
|
}
|
|
|
|
const cnDataImport = resolveCompactNumberDataImport(tag)
|
|
if (cnDataImport != null) {
|
|
;(locale.additionalImports ??= []).push({
|
|
from: cnDataImport,
|
|
resolve: false,
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
runtimeConfig: {
|
|
// @ts-ignore
|
|
apiBaseUrl: process.env.BASE_URL ?? globalThis.BASE_URL ?? getApiUrl(),
|
|
// @ts-ignore
|
|
rateLimitKey: process.env.RATE_LIMIT_IGNORE_KEY ?? globalThis.RATE_LIMIT_IGNORE_KEY,
|
|
pyroBaseUrl: process.env.PYRO_BASE_URL,
|
|
public: {
|
|
apiBaseUrl: getApiUrl(),
|
|
pyroBaseUrl: process.env.PYRO_BASE_URL,
|
|
siteUrl: getDomain(),
|
|
production: isProduction(),
|
|
featureFlagOverrides: getFeatureFlagOverrides(),
|
|
|
|
owner: process.env.VERCEL_GIT_REPO_OWNER || 'modrinth',
|
|
slug: process.env.VERCEL_GIT_REPO_SLUG || 'code',
|
|
branch:
|
|
process.env.VERCEL_GIT_COMMIT_REF ||
|
|
process.env.CF_PAGES_BRANCH ||
|
|
// @ts-ignore
|
|
globalThis.CF_PAGES_BRANCH ||
|
|
'master',
|
|
hash:
|
|
process.env.VERCEL_GIT_COMMIT_SHA ||
|
|
process.env.CF_PAGES_COMMIT_SHA ||
|
|
// @ts-ignore
|
|
globalThis.CF_PAGES_COMMIT_SHA ||
|
|
'unknown',
|
|
|
|
stripePublishableKey:
|
|
process.env.STRIPE_PUBLISHABLE_KEY ||
|
|
globalThis.STRIPE_PUBLISHABLE_KEY ||
|
|
'pk_test_51JbFxJJygY5LJFfKV50mnXzz3YLvBVe2Gd1jn7ljWAkaBlRz3VQdxN9mXcPSrFbSqxwAb0svte9yhnsmm7qHfcWn00R611Ce7b',
|
|
},
|
|
},
|
|
typescript: {
|
|
shim: false,
|
|
strict: true,
|
|
typeCheck: false,
|
|
tsConfig: {
|
|
compilerOptions: {
|
|
moduleResolution: 'bundler',
|
|
allowImportingTsExtensions: true,
|
|
},
|
|
},
|
|
},
|
|
modules: ['@vintl/nuxt', '@pinia/nuxt'],
|
|
vintl: {
|
|
defaultLocale: 'en-US',
|
|
locales: [
|
|
{
|
|
tag: 'en-US',
|
|
meta: {
|
|
static: {
|
|
iso: 'en',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
storage: 'cookie',
|
|
parserless: 'only-prod',
|
|
seo: {
|
|
defaultLocaleHasParameter: false,
|
|
},
|
|
onParseError({ error, message, messageId, moduleId, parseMessage, parserOptions }) {
|
|
const errorMessage = String(error)
|
|
const modulePath = relative(__dirname, moduleId)
|
|
|
|
try {
|
|
const fallback = parseMessage(message, { ...parserOptions, ignoreTag: true })
|
|
|
|
consola.warn(
|
|
`[i18n] ${messageId} in ${modulePath} cannot be parsed normally due to ${errorMessage}. The tags will will not be parsed.`,
|
|
)
|
|
|
|
return fallback
|
|
} catch (err) {
|
|
const secondaryErrorMessage = String(err)
|
|
|
|
const reason =
|
|
errorMessage === secondaryErrorMessage
|
|
? errorMessage
|
|
: `${errorMessage} and ${secondaryErrorMessage}`
|
|
|
|
consola.warn(
|
|
`[i18n] ${messageId} in ${modulePath} cannot be parsed due to ${reason}. It will be skipped.`,
|
|
)
|
|
}
|
|
},
|
|
},
|
|
nitro: {
|
|
moduleSideEffects: ['@vintl/compact-number/locale-data'],
|
|
rollupConfig: {
|
|
// @ts-expect-error it's not infinite.
|
|
plugins: [serverSidedVue()],
|
|
},
|
|
},
|
|
devtools: {
|
|
enabled: true,
|
|
},
|
|
css: ['~/assets/styles/tailwind.css'],
|
|
postcss: {
|
|
plugins: {
|
|
tailwindcss: {},
|
|
autoprefixer: {},
|
|
},
|
|
},
|
|
routeRules: {
|
|
'/**': {
|
|
headers: {
|
|
'Accept-CH': 'Sec-CH-Prefers-Color-Scheme',
|
|
'Critical-CH': 'Sec-CH-Prefers-Color-Scheme',
|
|
},
|
|
},
|
|
'/dashboard/revenue/withdraw': {
|
|
redirect: {
|
|
to: '/dashboard/revenue',
|
|
statusCode: 410,
|
|
},
|
|
},
|
|
'/email/**': {
|
|
redirect: '/_internal/templates/email/**',
|
|
},
|
|
'/_internal/templates/email/**': {
|
|
prerender: true,
|
|
headers: {
|
|
'Content-Type': 'text/html',
|
|
'Cache-Control': 'public, max-age=3600',
|
|
},
|
|
},
|
|
'/_internal/templates/doc/**': {
|
|
prerender: true,
|
|
headers: {
|
|
'Content-Type': 'text/html',
|
|
'Cache-Control': 'public, max-age=3600',
|
|
},
|
|
},
|
|
},
|
|
compatibilityDate: '2024-07-03',
|
|
telemetry: false,
|
|
})
|
|
|
|
function getApiUrl() {
|
|
// @ts-ignore
|
|
return process.env.BROWSER_BASE_URL ?? globalThis.BROWSER_BASE_URL ?? STAGING_API_URL
|
|
}
|
|
|
|
function isProduction() {
|
|
return process.env.NODE_ENV === 'production'
|
|
}
|
|
|
|
function getFeatureFlagOverrides() {
|
|
return JSON.parse(process.env.FLAG_OVERRIDES ?? '{}')
|
|
}
|
|
|
|
function getDomain() {
|
|
if (process.env.NODE_ENV === 'production') {
|
|
if (process.env.SITE_URL) {
|
|
return process.env.SITE_URL
|
|
}
|
|
// @ts-ignore
|
|
else if (process.env.CF_PAGES_URL || globalThis.CF_PAGES_URL) {
|
|
// @ts-ignore
|
|
return process.env.CF_PAGES_URL ?? globalThis.CF_PAGES_URL
|
|
} else if (process.env.HEROKU_APP_NAME) {
|
|
return `https://${process.env.HEROKU_APP_NAME}.herokuapp.com`
|
|
} else if (process.env.VERCEL_URL) {
|
|
return `https://${process.env.VERCEL_URL}`
|
|
} else if (getApiUrl() === STAGING_API_URL) {
|
|
return 'https://staging.modrinth.com'
|
|
} else {
|
|
return 'https://modrinth.com'
|
|
}
|
|
} else {
|
|
const port = process.env.PORT || 3000
|
|
return `http://localhost:${port}`
|
|
}
|
|
}
|