diff --git a/package-lock.json b/package-lock.json index 91b5752..61d9f3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1164,6 +1164,11 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + }, "hexo": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/hexo/-/hexo-3.7.1.tgz", @@ -1636,6 +1641,16 @@ "striptags": "2.2.1" } }, + "hexo-wordcount": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/hexo-wordcount/-/hexo-wordcount-3.0.2.tgz", + "integrity": "sha512-/T8pWaJyGjVO66nFDK2WyhSuv9xzMMohXlyqqg3HWCv5mYLG6cdzGcn5TNOgKWUAqRLcNF/96036utrTFW/Xrw==", + "requires": { + "html-to-text": "2.1.3", + "numeral": "1.5.6", + "wordcount": "1.1.1" + } + }, "highlight.js": { "version": "9.12.0", "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", @@ -1646,6 +1661,39 @@ "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" }, + "html-to-text": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-2.1.3.tgz", + "integrity": "sha1-5Q2+TkB5kS2+3N4F0ng4jtuO6pE=", + "requires": { + "he": "1.1.1", + "htmlparser": "1.7.7", + "optimist": "0.6.1", + "underscore": "1.9.1", + "underscore.string": "3.3.4" + }, + "dependencies": { + "underscore": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" + }, + "underscore.string": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.4.tgz", + "integrity": "sha1-LCo/n4PmR2L9xF5s6sZRQoZCE9s=", + "requires": { + "sprintf-js": "1.0.3", + "util-deprecate": "1.0.2" + } + } + } + }, + "htmlparser": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/htmlparser/-/htmlparser-1.7.7.tgz", + "integrity": "sha1-GeezmX/2+6yZrlp9J2ZInv5+LQ4=" + }, "htmlparser2": { "version": "3.9.2", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.9.2.tgz", @@ -1964,6 +2012,14 @@ "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==" }, + "match-words": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/match-words/-/match-words-0.1.1.tgz", + "integrity": "sha1-3NMRnnSmpnvkMEylz5JlgOjhp68=", + "requires": { + "word-regex": "0.1.2" + } + }, "micromatch": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", @@ -2138,6 +2194,11 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, + "numeral": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/numeral/-/numeral-1.5.6.tgz", + "integrity": "sha1-ODHbloRRuc9q/5v5WSXx7443sz8=" + }, "nunjucks": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/nunjucks/-/nunjucks-3.1.2.tgz", @@ -2708,6 +2769,19 @@ "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=" }, + "word-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/word-regex/-/word-regex-0.1.2.tgz", + "integrity": "sha1-o7x/LSIs5Kk8JGw+9pRY9h9RFjk=" + }, + "wordcount": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/wordcount/-/wordcount-1.1.1.tgz", + "integrity": "sha1-5y2ngzkE2HChVMnvR+1fPnmXz1c=", + "requires": { + "match-words": "0.1.1" + } + }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", diff --git a/package.json b/package.json index ec3d9a4..354e9b7 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "hexo-renderer-ejs": "^0.3.0", "hexo-renderer-marked": "^0.3.0", "hexo-renderer-stylus": "^0.3.1", - "hexo-server": "^0.2.0" + "hexo-server": "^0.2.0", + "hexo-wordcount": "^3.0.2" }, "devDependencies": { "hexo-deployer-git": "^0.3.1" diff --git a/themes/yilia/layout/_partial/article.ejs b/themes/yilia/layout/_partial/article.ejs index 2b83670..9c8fec8 100644 --- a/themes/yilia/layout/_partial/article.ejs +++ b/themes/yilia/layout/_partial/article.ejs @@ -12,6 +12,10 @@ <% if (post.excerpt && index){ %> <%- post.excerpt %> <% } else { %> +
'+n+""),console)},r.prototype.installLocale=function(e,t){var n=this;return t=t||{},p[e]=JSON.stringify(Object.keys(p["zh-cn"]))==JSON.stringify(Object.keys(t))?t:void 0,n.locale=p[e]||p["zh-cn"],n},r.prototype.setPath=function(e){return g=e||g,this},r.prototype.bind=function(e){var t=this,n=t.el.querySelector(".vemojis"),r=t.el.querySelector(".vemoji-btn"),i=t.el.querySelector(".vpreview"),p=function(e){var t=e.value||"";t=u.parse(t),e.value=t;var n=s(t);d.comment=n,i.innerHTML=n},f=u.data;for(var b in f)f.hasOwnProperty(b)&&function(e,t){var r=document.createElement("i");r.setAttribute("name",e),r.setAttribute("title",e),r.innerHTML=t,n.appendChild(r),o.Event.on("click",r,function(e){var n=document.querySelector(".veditor");A(n,t),p(n)})}(b,f[b]);o.Event.on("click",r,function(e){r.getAttribute("v")?(r.removeAttribute("v"),n.setAttribute("style","display:none")):(r.setAttribute("v",1),O.removeAttribute("v"),i.setAttribute("style","display:none"),n.setAttribute("style","display:block"))});for(var x=e.guest_info,y={},k={veditor:"comment"},w=0,S=x.length;w
"+s(e.message+"",!0)+"";throw e}}var f={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:d,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:d,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:d,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,text:/^[^\n]+/};f._label=/(?:\\[\[\]]|[^\[\]])+/,f._title=/(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/,f.def=c(f.def).replace("label",f._label).replace("title",f._title).getRegex(),f.bullet=/(?:[*+-]|\d+\.)/,f.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,f.item=c(f.item,"gm").replace(/bull/g,f.bullet).getRegex(),f.list=c(f.list).replace(/bull/g,f.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+f.def.source+")").getRegex(),f._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b",f.html=c(f.html).replace("comment",//).replace("closed",/<(tag)[\s\S]+?<\/\1>/).replace("closing",/
'+(n?e:s(e,!0))+"\n\n":""+(n?e:s(e,!0))+"\n"},i.prototype.blockquote=function(e){return"\n"+e+"\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"
"+e+"
\n"},i.prototype.table=function(e,t){return""+e+""},i.prototype.br=function(){return this.options.xhtml?"'+n+""),console)},r.prototype.installLocale=function(e,t){var n=this;return t=t||{},p[e]=JSON.stringify(Object.keys(p["zh-cn"]))==JSON.stringify(Object.keys(t))?t:void 0,n.locale=p[e]||p["zh-cn"],n},r.prototype.setPath=function(e){return g=e||g,this},r.prototype.bind=function(e){var t=this,n=t.el.querySelector(".vemojis"),r=t.el.querySelector(".vemoji-btn"),i=t.el.querySelector(".vpreview"),p=function(e){var t=e.value||"";t=u.parse(t),e.value=t;var n=s(t);d.comment=n,i.innerHTML=n},f=u.data;for(var b in f)f.hasOwnProperty(b)&&function(e,t){var r=document.createElement("i");r.setAttribute("name",e),r.setAttribute("title",e),r.innerHTML=t,n.appendChild(r),o.Event.on("click",r,function(e){var n=document.querySelector(".veditor");A(n,t),p(n)})}(b,f[b]);o.Event.on("click",r,function(e){r.getAttribute("v")?(r.removeAttribute("v"),n.setAttribute("style","display:none")):(r.setAttribute("v",1),O.removeAttribute("v"),i.setAttribute("style","display:none"),n.setAttribute("style","display:block"))});for(var x=e.guest_info,y={},k={veditor:"comment"},w=0,S=x.length;w
"+s(e.message+"",!0)+"";throw e}}var f={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:d,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:d,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:d,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,text:/^[^\n]+/};f._label=/(?:\\[\[\]]|[^\[\]])+/,f._title=/(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/,f.def=c(f.def).replace("label",f._label).replace("title",f._title).getRegex(),f.bullet=/(?:[*+-]|\d+\.)/,f.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,f.item=c(f.item,"gm").replace(/bull/g,f.bullet).getRegex(),f.list=c(f.list).replace(/bull/g,f.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+f.def.source+")").getRegex(),f._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b",f.html=c(f.html).replace("comment",//).replace("closed",/<(tag)[\s\S]+?<\/\1>/).replace("closing",/
'+(n?e:s(e,!0))+"\n\n":""+(n?e:s(e,!0))+"\n"},i.prototype.blockquote=function(e){return"\n"+e+"\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"
"+e+"
\n"},i.prototype.table=function(e,t){return""+e+""},i.prototype.br=function(){return this.options.xhtml?"'+n+""),console)},r.prototype.installLocale=function(e,t){var n=this;return t=t||{},p[e]=(0,l.default)((0,u.default)(p["zh-cn"]))==(0,l.default)((0,u.default)(t))?t:void 0,n.locale=p[e]||p["zh-cn"],n},r.prototype.setPath=function(e){return m=e||m,this},r.prototype.bind=function(e){var t=this,n=t.el.querySelector(".vemojis"),r=t.el.querySelector(".vemoji-btn"),i=t.el.querySelector(".vpreview"),u=function(e){var t=e.value||"";t=f.parse(t),e.value=t;var n=a(t);d.comment=n,i.innerHTML=n},p=f.data;for(var _ in p)p.hasOwnProperty(_)&&function(e,t){var r=document.createElement("i");r.setAttribute("name",e),r.setAttribute("title",e),r.innerHTML=t,n.appendChild(r),o.Event.on("click",r,function(e){var n=document.querySelector(".veditor");E(n,t),u(n)})}(_,p[_]);o.Event.on("click",r,function(e){r.getAttribute("v")?(r.removeAttribute("v"),n.setAttribute("style","display:none")):(r.setAttribute("v",1),k.removeAttribute("v"),i.setAttribute("style","display:none"),n.setAttribute("style","display:block"))});for(var b=e.guest_info,w={},O={veditor:"comment"},x=0,S=b.length;x
"+a(e.message+"",!0)+"";throw e}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:h,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:h,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:h,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,text:/^[^\n]+/};p._label=/(?:\\[\[\]]|[^\[\]])+/,p._title=/(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/,p.def=c(p.def).replace("label",p._label).replace("title",p._title).getRegex(),p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=c(p.item,"gm").replace(/bull/g,p.bullet).getRegex(),p.list=c(p.list).replace(/bull/g,p.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+p.def.source+")").getRegex(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b",p.html=c(p.html).replace("comment",//).replace("closed",/<(tag)[\s\S]+?<\/\1>/).replace("closing",/
'+(n?e:a(e,!0))+"\n\n":""+(n?e:a(e,!0))+"\n"},i.prototype.blockquote=function(e){return"\n"+e+"\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"
"+e+"
\n"},i.prototype.table=function(e,t){return""+e+""},i.prototype.br=function(){return this.options.xhtml?"'+n+""),console)},r.prototype.installLocale=function(e,t){var n=this;return t=t||{},p[e]=(0,l.default)((0,u.default)(p["zh-cn"]))==(0,l.default)((0,u.default)(t))?t:void 0,n.locale=p[e]||p["zh-cn"],n},r.prototype.setPath=function(e){return m=e||m,this},r.prototype.bind=function(e){var t=this,n=t.el.querySelector(".vemojis"),r=t.el.querySelector(".vemoji-btn"),i=t.el.querySelector(".vpreview"),u=function(e){var t=e.value||"";t=f.parse(t),e.value=t;var n=a(t);d.comment=n,i.innerHTML=n},p=f.data;for(var _ in p)p.hasOwnProperty(_)&&function(e,t){var r=document.createElement("i");r.setAttribute("name",e),r.setAttribute("title",e),r.innerHTML=t,n.appendChild(r),o.Event.on("click",r,function(e){var n=document.querySelector(".veditor");E(n,t),u(n)})}(_,p[_]);o.Event.on("click",r,function(e){r.getAttribute("v")?(r.removeAttribute("v"),n.setAttribute("style","display:none")):(r.setAttribute("v",1),k.removeAttribute("v"),i.setAttribute("style","display:none"),n.setAttribute("style","display:block"))});for(var b=e.guest_info,w={},O={veditor:"comment"},x=0,S=b.length;x
"+a(e.message+"",!0)+"";throw e}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:h,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:h,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,table:h,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,paragraph:/^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,text:/^[^\n]+/};p._label=/(?:\\[\[\]]|[^\[\]])+/,p._title=/(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/,p.def=c(p.def).replace("label",p._label).replace("title",p._title).getRegex(),p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=c(p.item,"gm").replace(/bull/g,p.bullet).getRegex(),p.list=c(p.list).replace(/bull/g,p.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+p.def.source+")").getRegex(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b",p.html=c(p.html).replace("comment",//).replace("closed",/<(tag)[\s\S]+?<\/\1>/).replace("closing",/
'+(n?e:a(e,!0))+"\n\n":""+(n?e:a(e,!0))+"\n"},i.prototype.blockquote=function(e){return"\n"+e+"\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"
"+e+"
\n"},i.prototype.table=function(e,t){return""+e+""},i.prototype.br=function(){return this.options.xhtml?"