Skip to content

Commit 3e60a9e

Browse files
committed
refactor(env): explicitly specify env type
1 parent 38edac2 commit 3e60a9e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ENV_NAME=DEVELOPMENT
12
BASE_PATH=/blog/
23

34
# GISCUS Configs: generated from https://giscus.app/

.vitepress/config.utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export function joinURL(baseURL: string, ...paths: string[]) {
2323
return new URL(urlPath, baseURL).href;
2424
}
2525

26-
export function isProduction() {
27-
return !BASE_PATH;
28-
}
26+
export const appEnv = {
27+
envName: env.ENV_NAME,
28+
isDevelopment: env.ENV_NAME === "DEVELOPMENT",
29+
isTesting: env.ENV_NAME === "TESTING",
30+
isStaging: env.ENV_NAME === "STAGING",
31+
isProduction: env.ENV_NAME === "PRODUCTION",
32+
};

.vitepress/theme/posts.loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { createContentLoader } from "vitepress";
33
import readingTime from "reading-time";
44
import extendedConfig from "../config.theme";
5-
import { withBaseURL, isProduction } from "../config.utils";
5+
import { appEnv, withBaseURL } from "../config.utils";
66
import getLocation from "./locations";
77

88
// Title Workaround
@@ -26,7 +26,7 @@ function transformRawData(rawData) {
2626
p.frontmatter.mdpath = mdpath;
2727
return p;
2828
})
29-
.filter(p => !isProduction() || !p.frontmatter.draft)
29+
.filter(p => !appEnv.isProduction || !p.frontmatter.draft)
3030
.sort((a, b) => {
3131
return b.frontmatter.datetime - a.frontmatter.datetime;
3232
});

0 commit comments

Comments
 (0)