├── .gitignore ├── LICENSE ├── README.md ├── index.js ├── lib └── deployer.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .directory 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This work is free. You can redistribute it and/or modify it under the 2 | terms of the Do What The Fuck You Want To Public License, Version 2, 3 | as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hexo-deployer-netlify 2 | 3 | Netlify deployer plugin for [Hexo]. 4 | 5 | ## Installation 6 | 7 | ``` bash 8 | $ npm install hexo-deployer-netlify --save 9 | ``` 10 | 11 | ## Options 12 | 13 | You can configure this plugin in `_config.yml`. 14 | 15 | ``` yaml 16 | # You can use this: 17 | deploy: 18 | type: netlify 19 | token: 20 | site_id: 21 | ``` 22 | 23 | - **token**: Netlify personal access token (you can create one at https://app.netlify.com/applications). It should be a long base64 string, i.e. 'aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00aa00' 24 | - **site_id**: Your site api ID. Should be an UID, something like '11bb11bb-11bb-11bb-11bb-11bb11bb11bb'. You can find it in "Site Info" section, at the bottom of https://app.netlify.com/sites/my-blog-name. 25 | 26 | ## License 27 | 28 | WTFPL 29 | 30 | [Hexo]: http://hexo.io/ 31 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let deployer = require('./lib/deployer') 4 | hexo.extend.deployer.register('netlify', module.exports = (args) => deployer( args , hexo ) ) 5 | -------------------------------------------------------------------------------- /lib/deployer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let fs = require('hexo-fs') 4 | let path = require('path') 5 | let Netlify = require('netlify') 6 | 7 | let deployer = (args, dir) => 8 | new Netlify(args.token).deploy(args.site_id, dir) 9 | .then(() => console.log("hexo-deployer-netlify: Deployed!")) 10 | .catch(err => console.error(`hexo-deployer-netlify: Error while deploying: ${err}`)); 11 | 12 | module.exports = (args, hexo) => 13 | new Promise((resolve, reject) => { 14 | if(!args.token){ 15 | reject(new Error('hexo-deployer-netlify: plugin is not configured, you need to set token.')) 16 | }else if(!args.site_id){ 17 | reject(new Error('hexo-deployer-netlify: plugin is not configured, you need to set site_id.')) 18 | }else{ 19 | return deployer(args, path.resolve(hexo.public_dir)); 20 | } 21 | }) 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hexo-deployer-netlify", 3 | "version": "0.0.7", 4 | "description": "Netlify deployer plugin of Hexo.", 5 | "main": "index", 6 | "directories": { 7 | "lib": "./lib" 8 | }, 9 | "repository": "piktaszuikis/hexo-deployer-netlify", 10 | "homepage": "https://hexo.io/", 11 | "keywords": [ 12 | "hexo", 13 | "netlify", 14 | "deploy", 15 | "deployer", 16 | "zip" 17 | ], 18 | "author": "Piktas Zuikis (http://piktas-zuikis.netlify.io/)", 19 | "license": "WTFPL", 20 | "dependencies": { 21 | "netlify": "^4.0.0", 22 | "hexo-fs": "^3.0.0" 23 | } 24 | } 25 | --------------------------------------------------------------------------------