Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
feat(environment): use hugo.Environment to judge the production envir…
Browse files Browse the repository at this point in the history
…onment
  • Loading branch information
dillonzq committed Mar 2, 2020
1 parent f83b1c1 commit 285efc0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,6 @@

## 小技巧

### 在生成网站时设置 `production` 环境变量

由于主题的一些功能仅在生产环境有效,所以你需要在生成网站时设置 `production` 环境变量。

```bash
HUGO_ENV=production hugo --gc --minify
```

### 怎样切换网站 暗黑-明亮 模式

* 你可以点击圆形图标来切换网站 暗黑-明亮 模式。桌面模式下圆形图标在网页右上角,移动设备模式下在网站左上角标题旁边
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 285efc0

Please sign in to comment.