🚀 npm support

This commit is contained in:
沈宇 2020-08-24 12:20:00 +08:00
parent 505f34cd3f
commit 8b0ab2c38d
6 changed files with 68 additions and 17 deletions

21
.github/workflows/npmpublish.yml vendored Normal file
View File

@ -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}}

3
.npmignore Normal file
View File

@ -0,0 +1,3 @@
.cache/
.history/
.github/

View File

@ -42,13 +42,24 @@
![Screenshot](screenshots/hexo-theme-ayer.png) ![Screenshot](screenshots/hexo-theme-ayer.png)
### Install ## Install
``` bash ### For hexo < 5.0
$ git clone https://github.com/Shen-Yu/hexo-theme-ayer.git themes/ayer
``` 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` Modify `theme` setting in `_config.yml` to `ayer`
@ -56,19 +67,19 @@ Modify `theme` setting in `_config.yml` to `ayer`
theme: ayer theme: ayer
``` ```
### Update ## Update
``` bash ``` bash
cd themes/ayer cd themes/ayer
git pull git pull
``` ```
### Multi Language Support ## Multi Language Support
zh-CN中文简体 enEnglish zh-TW中文繁体 jaJapanese esSpanish deGerman frFrench ruRussian koKorean viVietnamese nlDutch noNorwegian ptPortuguese zh-CN中文简体 enEnglish zh-TW中文繁体 jaJapanese esSpanish deGerman frFrench ruRussian koKorean viVietnamese nlDutch noNorwegian ptPortuguese
English is default languge, if you want to change, modify `language` option in `_config.yml` file in your blog's root folder. 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. let me know if you have any questions.
@ -245,7 +256,7 @@ since: 2019
pageFooter: true pageFooter: true
``` ```
### Plugins ## Plugins
+ [hexo-generator-search](https://github.com/wzpan/hexo-generator-search) (for Local Search) + [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 uninstall hexo-generator-index --save
$ npm install hexo-generator-index-pin-top --save $ npm install hexo-generator-index-pin-top --save
``` ```
### Categories ## Categories
``` bash ``` bash
hexo new page categories hexo new page categories
``` ```
@ -301,10 +312,10 @@ layout: "categories"
--- ---
``` ```
### Tags ## Tags
Same as categories. 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. 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 ``` md
@ -318,7 +329,7 @@ albums: [
--- ---
``` ```
### Toc ## Toc
Use Tocbot to parse the title tags (h1~h6) in the content and insert the directory. Use Tocbot to parse the title tags (h1~h6) in the content and insert the directory.

2
index.js Normal file
View File

@ -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.

12
move_config.js Normal file
View File

@ -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')
}
}

View File

@ -1,10 +1,11 @@
{ {
"name": "ayer", "name": "hexo-theme-ayer",
"version": "1.8.2", "version": "1.8.2",
"description": "a clean and elegant theme for hexo.", "description": "a clean and elegant theme for hexo.",
"scripts": { "scripts": {
"dev": "parcel serve source-src/main.js -d source/dist", "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", "source": "source-src/main.js",
"repository": { "repository": {
@ -17,10 +18,11 @@
"blog", "blog",
"ayer" "ayer"
], ],
"author": "Shen-Yu", "author": "Shen-Yu <shenyu@hotmail.com>",
"license": "SATA", "license": "SATA",
"bugs": { "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": ".", "homepage": ".",
"devDependencies": { "devDependencies": {
@ -30,4 +32,4 @@
"postcss-modules": "^1.5.0" "postcss-modules": "^1.5.0"
}, },
"dependencies": {} "dependencies": {}
} }