Don't run Keystatic in production and export vars

This commit is contained in:
Korbs 2024-06-07 03:15:10 -04:00
parent 53f7d0b350
commit c0cecb5632
2 changed files with 47 additions and 6 deletions

View file

@ -1,9 +1,11 @@
import { defineConfig } from 'astro/config';
const SITE_NAME = import.meta.env.SITE_NAME;
const SITE_PROTOCOL = import.meta.env.SITE_PROTOCOL;
const SITE_DOMAIN = import.meta.env.SITE_DOMAIN;
const SITE_BASE = import.meta.env.SITE_BASE;
// Environment Variables
import {
SITE_PROTOCOL,
SITE_DOMAIN,
SITE_BASE
} from './src/utils/GetConfig'
// Adapters
import node from '@astrojs/node';
@ -12,21 +14,33 @@ import node from '@astrojs/node';
import keystatic from '@keystatic/astro';
import mdx from '@astrojs/mdx';
import partytown from '@astrojs/partytown';
import react from '@astrojs/react';
export default defineConfig({
// Information
site: SITE_PROTOCOL + '://' + SITE_DOMAIN,
base: SITE_BASE,
// Integrations
integrations: [
mdx(),
partytown(),
react(),
// Disable Keystatic in production
// https://keystatic.com/docs/recipes/astro-disable-admin-ui-in-production
...(process.env.SKIP_KEYSTATIC ? [] : [keystatic()])
],
// Server Output
output: "hybrid",
prefetch: true,
adapter: node({
mode: 'standalone',
}),
integrations: [mdx(), partytown()],
server: {
port: 2014,
host: true
},
// Others
devToolbar: {
enabled: false
}
});
});

27
src/utils/GetConfig.js Normal file
View file

@ -0,0 +1,27 @@
export var ORG_NAME = import.meta.env.ORG_NAME;
export var SITE_NAME = import.meta.env.SITE_NAME;
export var SITE_PROTOCOL = import.meta.env.SITE_PROTOCOL;
export var SITE_DOMAIN = import.meta.env.SITE_DOMAIN;
export var SITE_BASE = import.meta.env.SITE_BASE;
export var META_COLOR = import.meta.env.META_COLOR;
export var COLOR = import.meta.env.COLOR;
export var THEME = import.meta.env.THEME;
export var SIDEBAR_SIZE = import.meta.env.SIDEBAR_SIZE;
export var SIDEBAR_ICONS = import.meta.env.SIDEBAR_ICONS;
export var THEME_TOGGLE_ENABLED = import.meta.env.THEME_TOGGLE_ENABLED;
export var THEME_TOGGLE_STYLE = import.meta.env.THEME_TOGGLE_STYLE;
export var CMS_DASHBOARD_LOGO_DARK = import.meta.env.CMS_DASHBOARD_LOGO_DARK;
export var CMS_DASHBOARD_LOGO_LIGHT = import.meta.env.CMS_DASHBOARD_LOGO_LIGHT;
export var WHITELABEL = import.meta.env.WHITELABEL;
export var FOOTER_VERSION = import.meta.env.FOOTER_VERSION;
export var REVERT_LAYOUT = import.meta.env.REVERT_LAYOUT;
export var FEEDBACK_ENABLED = import.meta.env.FEEDBACK_ENABLED;
export var FEELBACK_ENABLED = import.meta.env.FEELBACK_ENABLED;
export var ANALYTICS = import.meta.env.ANALYTICS;
export var MATOMO_ID = import.meta.env.MATOMO_ID;
export var MATOMO_SRC = import.meta.env.MATOMO_SRC;
export var PLAUSIBLE_DOMAIN = import.meta.env.PLAUSIBLE_DOMAIN;
export var PLAUSIBLE_SRC = import.meta.env.PLAUSIBLE_SRC;
export var UMAMI_ID = import.meta.env.UMAMI_ID;
export var UMAMI_SRC = import.meta.env.UMAMI_SRC;
export var AMPLITUDE_APIKEY = import.meta.env.AMPLITUDE_APIKEY;