From 8b0ab2c38d4fc0613f6278836d932f7e6cffcc62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=AE=87?= <448766534@qq.com> Date: Mon, 24 Aug 2020 12:20:00 +0800 Subject: [PATCH] :rocket: npm support --- .github/workflows/npmpublish.yml | 21 +++++++++++++++++++ .npmignore | 3 +++ README.md | 35 +++++++++++++++++++++----------- index.js | 2 ++ move_config.js | 12 +++++++++++ package.json | 12 ++++++----- 6 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/npmpublish.yml create mode 100644 .npmignore create mode 100644 index.js create mode 100644 move_config.js diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml new file mode 100644 index 0000000..c4740ed --- /dev/null +++ b/.github/workflows/npmpublish.yml @@ -0,0 +1,21 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..f589258 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +.cache/ +.history/ +.github/ \ No newline at end of file diff --git a/README.md b/README.md index b0a2aa3..0301179 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,24 @@ ![Screenshot](screenshots/hexo-theme-ayer.png) -### Install +## Install -``` bash -$ git clone https://github.com/Shen-Yu/hexo-theme-ayer.git themes/ayer +### For hexo < 5.0 + +``` shell +git clone https://github.com/Shen-Yu/hexo-theme-ayer.git themes/ayer ``` -### Enable +### For hexo >= 5.0 + +``` shell +npm i hexo-theme-ayer -S +``` + +- If this theme is newly installed, a `_config.ayer.yml` file will be generated in the root directory after the installation is complete, and you can directly edit the `_config.ayer.yml` file for configuration. +- If it is a theme upgrade, you can use the configuration method of hexo < 5.0, or you can move the original configuration file to the root directory and rename it to `_config.ayer.yml`. + +## Enable Modify `theme` setting in `_config.yml` to `ayer` @@ -56,19 +67,19 @@ Modify `theme` setting in `_config.yml` to `ayer` theme: ayer ``` -### Update +## Update ``` bash cd themes/ayer git pull ``` -### Multi Language Support +## Multi Language Support zh-CN(中文简体) en(English) zh-TW(中文繁体) ja(Japanese) es(Spanish) de(German) fr(French) ru(Russian) ko(Korean) vi(Vietnamese) nl(Dutch) no(Norwegian) pt(Portuguese) English is default languge, if you want to change, modify `language` option in `_config.yml` file in your blog's root folder. -### Configuration +## Configuration let me know if you have any questions. @@ -245,7 +256,7 @@ since: 2019 pageFooter: true ``` -### Plugins +## Plugins + [hexo-generator-search](https://github.com/wzpan/hexo-generator-search) (for Local Search) @@ -288,7 +299,7 @@ pageFooter: true $ npm uninstall hexo-generator-index --save $ npm install hexo-generator-index-pin-top --save ``` -### Categories +## Categories ``` bash hexo new page categories ``` @@ -301,10 +312,10 @@ layout: "categories" --- ``` -### Tags +## Tags Same as categories. -### Gallery +## Gallery Need to write in the head of the markdown, this is not a good way to write, I hope to get a better way to write on github. ``` md @@ -318,7 +329,7 @@ albums: [ --- ``` -### Toc +## Toc Use Tocbot to parse the title tags (h1~h6) in the content and insert the directory. diff --git a/index.js b/index.js new file mode 100644 index 0000000..fdb66cd --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +// 这个文件用来防止 hexo 5.0.0以上 使用 "hexo clean" 命令报错。 +// This file is used to prevent hexo above 5.0.0 from using "hexo clean" command error. \ No newline at end of file diff --git a/move_config.js b/move_config.js new file mode 100644 index 0000000..dab9b1a --- /dev/null +++ b/move_config.js @@ -0,0 +1,12 @@ +const fs = require('fs') + +if (fs.existsSync('../hexo/package.json')) { + const version = JSON.parse(fs.readFileSync('../hexo/package.json')).version + if (version.split('.')[0] === '5') { + const configPath = '../../_config.ayer.yml' + if (!fs.existsSync(configPath)) { + fs.writeFileSync(configPath, fs.readFileSync('./_config.yml')) + } + fs.unlinkSync('./_config.yml') + } +} \ No newline at end of file diff --git a/package.json b/package.json index 3b14bfd..d94cf54 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { - "name": "ayer", + "name": "hexo-theme-ayer", "version": "1.8.2", "description": "a clean and elegant theme for hexo.", "scripts": { "dev": "parcel serve source-src/main.js -d source/dist", - "build": "rimraf source/dist && parcel build source-src/main.js -d source/dist --no-source-maps" + "build": "rimraf source/dist && parcel build source-src/main.js -d source/dist --no-source-maps", + "postinstall": "node ./move_config.js" }, "source": "source-src/main.js", "repository": { @@ -17,10 +18,11 @@ "blog", "ayer" ], - "author": "Shen-Yu", + "author": "Shen-Yu ", "license": "SATA", "bugs": { - "url": "https://github.com/Shen-Yu/hexo-theme-ayer/issues" + "url": "https://github.com/Shen-Yu/hexo-theme-ayer/issues", + "email": "shenyu@hotmail.com" }, "homepage": ".", "devDependencies": { @@ -30,4 +32,4 @@ "postcss-modules": "^1.5.0" }, "dependencies": {} -} +} \ No newline at end of file