From 285efc01bbd6ff84f025b1acc5060233185e2f01 Mon Sep 17 00:00:00 2001 From: Dillon Date: Mon, 2 Mar 2020 17:03:35 +0800 Subject: [PATCH] feat(environment): use hugo.Environment to judge the production environment --- .circleci/config.yml | 2 +- README.md | 8 -------- README.zh.md | 8 -------- layouts/_default/baseof.html | 2 +- package.json | 2 +- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b13f3452..4752606c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ jobs: - checkout - run: git submodule sync - run: git submodule update --init - - run: HUGO_ENV=production hugo --source=exampleSite -v --gc + - run: hugo --source=exampleSite -v --gc - run: htmlproofer exampleSite/public --check-html --allow-hash-href --empty-alt-ignore --disable-external workflows: diff --git a/README.md b/README.md index 25210d26..5cabbda7 100644 --- a/README.md +++ b/README.md @@ -158,14 +158,6 @@ Customize `browserconfig.xml` and `site.webmanifest` to set theme-color and back ## Tips -### Set `production` environment when generating site - -Because some features are only in production mode, so you need to add a `production` environment variables when generating your site. - -```bash - HUGO_ENV=production hugo --gc --minify -``` - ### How to toggle dark-light mode * You can click the circle icon to toggle dark-light mode. In the desktop version the circle icon is to the right and in the mobile version is positioned to the left, close to the site title. diff --git a/README.zh.md b/README.zh.md index e7d91268..2e6374a5 100644 --- a/README.zh.md +++ b/README.zh.md @@ -153,14 +153,6 @@ ## 小技巧 -### 在生成网站时设置 `production` 环境变量 - -由于主题的一些功能仅在生产环境有效,所以你需要在生成网站时设置 `production` 环境变量。 - -```bash - HUGO_ENV=production hugo --gc --minify -``` - ### 怎样切换网站 暗黑-明亮 模式 * 你可以点击圆形图标来切换网站 暗黑-明亮 模式。桌面模式下圆形图标在网页右上角,移动设备模式下在网站左上角标题旁边 diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index dd6a7925..90f5b6fb 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -5,7 +5,7 @@ {{- $scratch := newScratch -}} {{- .Scratch.Set "scratch" $scratch -}} -{{- if eq (getenv "HUGO_ENV") "production" -}} +{{- if eq hugo.Environment "production" -}} {{- $scratch.Set "production" true -}} {{- $scratch.Set "CDN" .Site.Params.cdn -}} {{- end -}} diff --git a/package.json b/package.json index 099ced9f..565f3246 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "scripts": { "build": "npx babel src --out-file assets/js/theme.min.js --source-maps", "start": "hugo server --source=exampleSite --themesDir=../.. --disableFastRender -D", - "copy": "HUGO_ENV=production hugo -v --source=exampleSite --themesDir=../.. -D --gc --minify && rm -rf resources && cp -rf exampleSite/resources resources" + "copy": "hugo -v --source=exampleSite --themesDir=../.. -D --gc --minify && rm -rf resources && cp -rf exampleSite/resources resources" }, "husky": { "hooks": {