hexo-abbrlink
Advanced tools
Comparing version 2.0.2 to 2.0.4
'use strict'; | ||
var crc = require('./crc16'); | ||
var crc16 = require('./crc16'); | ||
var crc32 = require('./crc32'); | ||
var model = require('./model'); | ||
@@ -13,4 +14,10 @@ var front = require('hexo-front-matter'); | ||
if (!abbrlink) { | ||
let res = crc(data.title) >>> 0; | ||
abbrlink = model.check(res); | ||
var opt_alg = ((this.config.abbrlink && this.config.abbrlink.alg) ? this.config.abbrlink.alg : 'crc16'); | ||
var opt_rep = ((this.config.abbrlink && this.config.abbrlink.rep) ? this.config.abbrlink.rep : 'dec') | ||
let res = (opt_alg == 'crc32' ? crc32.str(data.title) >>> 0 : crc16(data.title) >>> 0); | ||
//check this abbrlink is already exist then get a different one | ||
abbrlink = model.check(res); | ||
//set abbrlink to hex or dec | ||
abbrlink = opt_rep == 'hex' ? abbrlink.toString(16) : abbrlink; | ||
data.abbrlink = abbrlink; | ||
@@ -17,0 +24,0 @@ //re parse front matter |
{ | ||
"name": "hexo-abbrlink", | ||
"version": "2.0.2", | ||
"version": "2.0.4", | ||
"description": "create one and only link for every post for hexo", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# hexo-abbrlink | ||
A [Hexo plugin](https://hexo.io/plugins/) to generate static post link based on post title and time. | ||
A [Hexo plugin](https://hexo.io/plugins/) to generate static post link based on post titles. | ||
@@ -9,3 +9,3 @@ ## How to install | ||
``` | ||
``` | ||
npm install hexo-abbrlink --save | ||
@@ -20,15 +20,46 @@ ``` | ||
There are two settings: | ||
``` | ||
alg -- Algorithm (currently support crc16 and crc32, which crc16 is default) | ||
rep -- Represent (the generated link could be presented in hex or dec value) | ||
``` | ||
``` | ||
# abbrlink config | ||
abbrlink: | ||
alg: crc32 #support crc16(default) and crc32 | ||
rep: hex #support dec(default) and hex | ||
``` | ||
## Sample | ||
The generated link will look like the following: | ||
``` | ||
crc16 & hex | ||
https://post.zz173.com/posts/66c8.html | ||
crc16 & dec | ||
https://post.zz173.com/posts/65535.html | ||
``` | ||
``` | ||
crc32 & hex | ||
https://post.zz173.com/posts/8ddf18fb.html | ||
crc32 & dec | ||
https://post.zz173.com/posts/1690090958.html | ||
``` | ||
## Limitation | ||
Maximum number of posts is 65535. (For a personal blog site, this number is decent) | ||
Maximum number of posts is 65535 for crc16. (For a personal blog site, this number is decent) | ||
## More info | ||
## More info | ||
see [this](https://post.zz173.com/detail/hexo-abbrlink.html)(Chinese) | ||
## ThanksFor | ||
[NoahDragon](https://github.com/NoahDragon) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10051
9
214
64