From 5657112dfb0e6eac2faa2ae1dc0978ed29030709 Mon Sep 17 00:00:00 2001 From: panda-z Date: Mon, 13 Apr 2020 21:18:35 +0800 Subject: [PATCH] chore(build): drop webpack and use Hugo Pipes (#130) --- .babelrc | 5 - README-zh.md | 15 +- README.md | 15 +- {src => assets}/js/even.js | 1 - {src => assets}/js/main.js | 4 - {src/css => assets/sass}/_base.scss | 0 .../sass}/_common/_animation.scss | 0 .../sass}/_common/_normalize.scss | 0 {src/css => assets/sass}/_common/_utils.scss | 0 {src/css => assets/sass}/_custom/_custom.scss | 0 {src/css => assets/sass}/_iconfont.scss | 0 {src/css => assets/sass}/_partial/_404.scss | 0 .../sass}/_partial/_archive.scss | 0 .../sass}/_partial/_back-to-top.scss | 0 .../css => assets/sass}/_partial/_footer.scss | 0 .../sass}/_partial/_footer/_copyright.scss | 0 .../sass}/_partial/_footer/_social.scss | 0 .../css => assets/sass}/_partial/_header.scss | 0 .../sass}/_partial/_header/_logo.scss | 0 .../sass}/_partial/_header/_menu.scss | 0 .../css => assets/sass}/_partial/_mobile.scss | 0 .../sass}/_partial/_pagination.scss | 0 {src/css => assets/sass}/_partial/_post.scss | 0 .../sass}/_partial/_post/_admonition.scss | 0 .../sass}/_partial/_post/_code.scss | 0 .../sass}/_partial/_post/_content.scss | 0 .../sass}/_partial/_post/_copyright.scss | 0 .../sass}/_partial/_post/_footer.scss | 0 .../sass}/_partial/_post/_header.scss | 0 .../sass}/_partial/_post/_outdated.scss | 0 .../sass}/_partial/_post/_reward.scss | 0 .../sass}/_partial/_post/_toc.scss | 0 .../sass}/_partial/_slideout.scss | 0 {src/css => assets/sass}/_partial/_terms.scss | 0 {src/css => assets/sass}/_variables.scss | 0 src/css/style.scss => assets/sass/main.scss | 0 layouts/partials/head.html | 3 +- layouts/partials/scripts.html | 5 +- package.json | 32 - postcss.config.js | 7 - .../fonts/chancery/apple-chancery-webfont.eot | Bin .../fonts/chancery/apple-chancery-webfont.svg | 0 .../fonts/chancery/apple-chancery-webfont.ttf | Bin .../chancery/apple-chancery-webfont.woff | Bin .../chancery/apple-chancery-webfont.woff2 | Bin {src => static}/fonts/iconfont/iconfont.eot | Bin {src => static}/fonts/iconfont/iconfont.svg | 0 {src => static}/fonts/iconfont/iconfont.ttf | Bin {src => static}/fonts/iconfont/iconfont.woff | Bin webpack.config.js | 87 - yarn.lock | 5664 ----------------- 51 files changed, 8 insertions(+), 5830 deletions(-) delete mode 100644 .babelrc rename {src => assets}/js/even.js (99%) rename {src => assets}/js/main.js (81%) rename {src/css => assets/sass}/_base.scss (100%) rename {src/css => assets/sass}/_common/_animation.scss (100%) rename {src/css => assets/sass}/_common/_normalize.scss (100%) rename {src/css => assets/sass}/_common/_utils.scss (100%) rename {src/css => assets/sass}/_custom/_custom.scss (100%) rename {src/css => assets/sass}/_iconfont.scss (100%) rename {src/css => assets/sass}/_partial/_404.scss (100%) rename {src/css => assets/sass}/_partial/_archive.scss (100%) rename {src/css => assets/sass}/_partial/_back-to-top.scss (100%) rename {src/css => assets/sass}/_partial/_footer.scss (100%) rename {src/css => assets/sass}/_partial/_footer/_copyright.scss (100%) rename {src/css => assets/sass}/_partial/_footer/_social.scss (100%) rename {src/css => assets/sass}/_partial/_header.scss (100%) rename {src/css => assets/sass}/_partial/_header/_logo.scss (100%) rename {src/css => assets/sass}/_partial/_header/_menu.scss (100%) rename {src/css => assets/sass}/_partial/_mobile.scss (100%) rename {src/css => assets/sass}/_partial/_pagination.scss (100%) rename {src/css => assets/sass}/_partial/_post.scss (100%) rename {src/css => assets/sass}/_partial/_post/_admonition.scss (100%) rename {src/css => assets/sass}/_partial/_post/_code.scss (100%) rename {src/css => assets/sass}/_partial/_post/_content.scss (100%) rename {src/css => assets/sass}/_partial/_post/_copyright.scss (100%) rename {src/css => assets/sass}/_partial/_post/_footer.scss (100%) rename {src/css => assets/sass}/_partial/_post/_header.scss (100%) rename {src/css => assets/sass}/_partial/_post/_outdated.scss (100%) rename {src/css => assets/sass}/_partial/_post/_reward.scss (100%) rename {src/css => assets/sass}/_partial/_post/_toc.scss (100%) rename {src/css => assets/sass}/_partial/_slideout.scss (100%) rename {src/css => assets/sass}/_partial/_terms.scss (100%) rename {src/css => assets/sass}/_variables.scss (100%) rename src/css/style.scss => assets/sass/main.scss (100%) delete mode 100644 package.json delete mode 100644 postcss.config.js rename {src => static}/fonts/chancery/apple-chancery-webfont.eot (100%) rename {src => static}/fonts/chancery/apple-chancery-webfont.svg (100%) rename {src => static}/fonts/chancery/apple-chancery-webfont.ttf (100%) rename {src => static}/fonts/chancery/apple-chancery-webfont.woff (100%) rename {src => static}/fonts/chancery/apple-chancery-webfont.woff2 (100%) rename {src => static}/fonts/iconfont/iconfont.eot (100%) rename {src => static}/fonts/iconfont/iconfont.svg (100%) rename {src => static}/fonts/iconfont/iconfont.ttf (100%) rename {src => static}/fonts/iconfont/iconfont.woff (100%) delete mode 100644 webpack.config.js delete mode 100644 yarn.lock diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 1063349..0000000 --- a/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "presets": ["@babel/preset-env"], - "plugins": ["@babel/plugin-transform-runtime"], - "ignore": [] -} diff --git a/README-zh.md b/README-zh.md index a98b090..2d44ae5 100644 --- a/README-zh.md +++ b/README-zh.md @@ -64,22 +64,9 @@ defaultContentLanguage = "en" # en / zh-cn / other... 主题提供了 `center`,` right`, `left`,` music`, `admonition` 这些 shortcodes,并支持为内置的 `figure` 设置 `center`,` right`, `left` 这三种 class 值。点击[这里](https://blog.olowolo.com/example-site/post/shortcodes/)查看详细内容。 -## Theme Color +## Theme Color 主题内置了五种颜色 ( Default | Mint Green | Cobalt Blue | Hot Pink | Dark Violet ),你可以通过改变 [`/src/css/_variable.scss`](https://github.com/olOwOlo/hugo-theme-even/blob/master/src/css/_variables.scss#L5-L8) 文件中 `$theme-color-config` 的值来改变主题的颜色。 - -## Build - -如果你更改了 `/src/` 目录下的任意文件,你需要重新编译它们。 -```bash -cd ./themes/even/ -# install dependencies -yarn install -# build -yarn build -``` - -_你需要先安装 **[Yarn](https://yarnpkg.com/)** 和 **[Node.js](https://nodejs.org/)**。_ ## Update Theme diff --git a/README.md b/README.md index ddc16d5..0b1becc 100644 --- a/README.md +++ b/README.md @@ -64,22 +64,9 @@ You can customize something for a single content in the content's front-matter. This theme provides `center`,` right`, `left`,` music`, `admonition` shortcodes, and support `center`,` right`, `left` class for the built-in `figure`. See more information from [there](https://blog.olowolo.com/example-site/post/shortcodes/). -## Theme Color +## Theme Color There are five built-in theme colors ( Default | Mint Green | Cobalt Blue | Hot Pink | Dark Violet ), you can config it by changing the `$theme-color-config` value in [`/src/css/_variable.scss`](https://github.com/olOwOlo/hugo-theme-even/blob/master/src/css/_variables.scss#L5-L8). - -## Build - -If you changed any file under `/src/`, you need to rebuild. -```bash -cd ./themes/even/ -# install dependencies -yarn install -# build -yarn build -``` - -_You need to install **[Yarn](https://yarnpkg.com/)** and **[Node.js](https://nodejs.org/)** first._ ## Update Theme diff --git a/src/js/even.js b/assets/js/even.js similarity index 99% rename from src/js/even.js rename to assets/js/even.js index 8f8497a..01b9200 100644 --- a/src/js/even.js +++ b/assets/js/even.js @@ -277,4 +277,3 @@ Even.responsiveTable = function() { } }; -export {Even} diff --git a/src/js/main.js b/assets/js/main.js similarity index 81% rename from src/js/main.js rename to assets/js/main.js index 4554e68..96db5db 100644 --- a/src/js/main.js +++ b/assets/js/main.js @@ -1,7 +1,3 @@ -import {Even} from './even.js' - -import '../css/style.scss' - $(document).ready(function () { Even.backToTop(); Even.mobileNavbar(); diff --git a/src/css/_base.scss b/assets/sass/_base.scss similarity index 100% rename from src/css/_base.scss rename to assets/sass/_base.scss diff --git a/src/css/_common/_animation.scss b/assets/sass/_common/_animation.scss similarity index 100% rename from src/css/_common/_animation.scss rename to assets/sass/_common/_animation.scss diff --git a/src/css/_common/_normalize.scss b/assets/sass/_common/_normalize.scss similarity index 100% rename from src/css/_common/_normalize.scss rename to assets/sass/_common/_normalize.scss diff --git a/src/css/_common/_utils.scss b/assets/sass/_common/_utils.scss similarity index 100% rename from src/css/_common/_utils.scss rename to assets/sass/_common/_utils.scss diff --git a/src/css/_custom/_custom.scss b/assets/sass/_custom/_custom.scss similarity index 100% rename from src/css/_custom/_custom.scss rename to assets/sass/_custom/_custom.scss diff --git a/src/css/_iconfont.scss b/assets/sass/_iconfont.scss similarity index 100% rename from src/css/_iconfont.scss rename to assets/sass/_iconfont.scss diff --git a/src/css/_partial/_404.scss b/assets/sass/_partial/_404.scss similarity index 100% rename from src/css/_partial/_404.scss rename to assets/sass/_partial/_404.scss diff --git a/src/css/_partial/_archive.scss b/assets/sass/_partial/_archive.scss similarity index 100% rename from src/css/_partial/_archive.scss rename to assets/sass/_partial/_archive.scss diff --git a/src/css/_partial/_back-to-top.scss b/assets/sass/_partial/_back-to-top.scss similarity index 100% rename from src/css/_partial/_back-to-top.scss rename to assets/sass/_partial/_back-to-top.scss diff --git a/src/css/_partial/_footer.scss b/assets/sass/_partial/_footer.scss similarity index 100% rename from src/css/_partial/_footer.scss rename to assets/sass/_partial/_footer.scss diff --git a/src/css/_partial/_footer/_copyright.scss b/assets/sass/_partial/_footer/_copyright.scss similarity index 100% rename from src/css/_partial/_footer/_copyright.scss rename to assets/sass/_partial/_footer/_copyright.scss diff --git a/src/css/_partial/_footer/_social.scss b/assets/sass/_partial/_footer/_social.scss similarity index 100% rename from src/css/_partial/_footer/_social.scss rename to assets/sass/_partial/_footer/_social.scss diff --git a/src/css/_partial/_header.scss b/assets/sass/_partial/_header.scss similarity index 100% rename from src/css/_partial/_header.scss rename to assets/sass/_partial/_header.scss diff --git a/src/css/_partial/_header/_logo.scss b/assets/sass/_partial/_header/_logo.scss similarity index 100% rename from src/css/_partial/_header/_logo.scss rename to assets/sass/_partial/_header/_logo.scss diff --git a/src/css/_partial/_header/_menu.scss b/assets/sass/_partial/_header/_menu.scss similarity index 100% rename from src/css/_partial/_header/_menu.scss rename to assets/sass/_partial/_header/_menu.scss diff --git a/src/css/_partial/_mobile.scss b/assets/sass/_partial/_mobile.scss similarity index 100% rename from src/css/_partial/_mobile.scss rename to assets/sass/_partial/_mobile.scss diff --git a/src/css/_partial/_pagination.scss b/assets/sass/_partial/_pagination.scss similarity index 100% rename from src/css/_partial/_pagination.scss rename to assets/sass/_partial/_pagination.scss diff --git a/src/css/_partial/_post.scss b/assets/sass/_partial/_post.scss similarity index 100% rename from src/css/_partial/_post.scss rename to assets/sass/_partial/_post.scss diff --git a/src/css/_partial/_post/_admonition.scss b/assets/sass/_partial/_post/_admonition.scss similarity index 100% rename from src/css/_partial/_post/_admonition.scss rename to assets/sass/_partial/_post/_admonition.scss diff --git a/src/css/_partial/_post/_code.scss b/assets/sass/_partial/_post/_code.scss similarity index 100% rename from src/css/_partial/_post/_code.scss rename to assets/sass/_partial/_post/_code.scss diff --git a/src/css/_partial/_post/_content.scss b/assets/sass/_partial/_post/_content.scss similarity index 100% rename from src/css/_partial/_post/_content.scss rename to assets/sass/_partial/_post/_content.scss diff --git a/src/css/_partial/_post/_copyright.scss b/assets/sass/_partial/_post/_copyright.scss similarity index 100% rename from src/css/_partial/_post/_copyright.scss rename to assets/sass/_partial/_post/_copyright.scss diff --git a/src/css/_partial/_post/_footer.scss b/assets/sass/_partial/_post/_footer.scss similarity index 100% rename from src/css/_partial/_post/_footer.scss rename to assets/sass/_partial/_post/_footer.scss diff --git a/src/css/_partial/_post/_header.scss b/assets/sass/_partial/_post/_header.scss similarity index 100% rename from src/css/_partial/_post/_header.scss rename to assets/sass/_partial/_post/_header.scss diff --git a/src/css/_partial/_post/_outdated.scss b/assets/sass/_partial/_post/_outdated.scss similarity index 100% rename from src/css/_partial/_post/_outdated.scss rename to assets/sass/_partial/_post/_outdated.scss diff --git a/src/css/_partial/_post/_reward.scss b/assets/sass/_partial/_post/_reward.scss similarity index 100% rename from src/css/_partial/_post/_reward.scss rename to assets/sass/_partial/_post/_reward.scss diff --git a/src/css/_partial/_post/_toc.scss b/assets/sass/_partial/_post/_toc.scss similarity index 100% rename from src/css/_partial/_post/_toc.scss rename to assets/sass/_partial/_post/_toc.scss diff --git a/src/css/_partial/_slideout.scss b/assets/sass/_partial/_slideout.scss similarity index 100% rename from src/css/_partial/_slideout.scss rename to assets/sass/_partial/_slideout.scss diff --git a/src/css/_partial/_terms.scss b/assets/sass/_partial/_terms.scss similarity index 100% rename from src/css/_partial/_terms.scss rename to assets/sass/_partial/_terms.scss diff --git a/src/css/_variables.scss b/assets/sass/_variables.scss similarity index 100% rename from src/css/_variables.scss rename to assets/sass/_variables.scss diff --git a/src/css/style.scss b/assets/sass/main.scss similarity index 100% rename from src/css/style.scss rename to assets/sass/main.scss diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d602390..7a9f3ea 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -61,7 +61,8 @@ {{- end -}} - +{{ $style := resources.Get "sass/main.scss" | toCSS | minify | fingerprint }} + {{ if .Site.Params.publicCDN.enable -}} {{ if .Site.Params.fancybox }}{{ .Site.Params.publicCDN.fancyboxCSS | safeHTML }}{{ end }} {{- else -}} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index de35229..16cec74 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -67,7 +67,10 @@ {{- end -}} {{- end }} - +{{ $even := resources.Get "js/even.js" }} +{{ $main := resources.Get "js/main.js" }} +{{ $js := slice $even $main | resources.Concat "js/main.js" | fingerprint }} + {{- if and (or .Params.mathjax (and .Site.Params.mathjax (ne .Params.mathjax false))) (or .IsPage .IsHome) }}