File tree Expand file tree Collapse file tree 10 files changed +34
-16
lines changed
Expand file tree Collapse file tree 10 files changed +34
-16
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ class Deployer {
1111 return this . store ;
1212 }
1313
14- get ( name ) {
14+ get ( name : string ) {
1515 return this . store [ name ] ;
1616 }
1717
18- register ( name , fn ) {
18+ register ( name : string , fn ) {
1919 if ( ! name ) throw new TypeError ( 'name is required' ) ;
2020 if ( typeof fn !== 'function' ) throw new TypeError ( 'fn must be a function' ) ;
2121
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class Generator {
1313 return this . store ;
1414 }
1515
16- get ( name ) {
16+ get ( name : string ) {
1717 return this . store [ name ] ;
1818 }
1919
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Helper {
1717 * @param {String } name - The name of the helper plugin
1818 * @returns {Function }
1919 */
20- get ( name ) {
20+ get ( name : string ) {
2121 return this . store [ name ] ;
2222 }
2323
@@ -26,7 +26,7 @@ class Helper {
2626 * @param {String } name - The name of the helper plugin
2727 * @param {Function } fn - The helper plugin function
2828 */
29- register ( name , fn ) {
29+ register ( name : string , fn ) {
3030 if ( ! name ) throw new TypeError ( 'name is required' ) ;
3131 if ( typeof fn !== 'function' ) throw new TypeError ( 'fn must be a function' ) ;
3232
Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ class Migrator {
1111 return this . store ;
1212 }
1313
14- get ( name ) {
14+ get ( name : string ) {
1515 return this . store [ name ] ;
1616 }
1717
18- register ( name , fn ) {
18+ register ( name : string , fn ) {
1919 if ( ! name ) throw new TypeError ( 'name is required' ) ;
2020 if ( typeof fn !== 'function' ) throw new TypeError ( 'fn must be a function' ) ;
2121
Original file line number Diff line number Diff line change 1+ interface Options {
2+ context ?: any ;
3+ args ?: any ;
4+ }
5+
16interface StoreFunction {
27 ( ...args : any [ ] ) : any ;
38 priority ?: number ;
49}
510
611interface Store {
7- [ key : string ] : StoreFunction [ ]
12+ [ key : string ] : StoreFunction
813}
914
1015class SyntaxHighlight {
@@ -14,17 +19,17 @@ class SyntaxHighlight {
1419 this . store = { } ;
1520 }
1621
17- register ( name , fn ) {
22+ register ( name : string , fn : StoreFunction ) {
1823 if ( typeof fn !== 'function' ) throw new TypeError ( 'fn must be a function' ) ;
1924
2025 this . store [ name ] = fn ;
2126 }
2227
23- query ( name ) {
28+ query ( name : string ) {
2429 return name && this . store [ name ] ;
2530 }
2631
27- exec ( name , options ) {
32+ exec ( name : string , options : Options ) {
2833 const fn = this . store [ name ] ;
2934
3035 if ( ! fn ) throw new TypeError ( `syntax highlighter ${ name } is not registered` ) ;
Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ class Hexo extends EventEmitter {
305305 require ( '../plugins/injector' ) ( this ) ;
306306 require ( '../plugins/processor' ) ( this ) ;
307307 require ( '../plugins/renderer' ) ( this ) ;
308- require ( '../plugins/tag' ) ( this ) ;
308+ require ( '../plugins/tag' ) . default ( this ) ;
309309
310310 // Load config
311311 return Promise . each ( [
Original file line number Diff line number Diff line change @@ -228,6 +228,7 @@ interface Data {
228228 content ?: string ;
229229 disableNunjucks ?: boolean ;
230230 markdown ?: object ;
231+ source ?: string ;
231232}
232233
233234class Post {
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ interface Data {
1010}
1111
1212const process = ( name , ctx ) => {
13- return Promise . filter ( ctx . model ( name ) . toArray ( ) , ( asset : warehouse . Schema ) => fs . exists ( asset . source ) . tap ( exist => {
13+ return Promise . filter ( ctx . model ( name ) . toArray ( ) , ( asset : warehouse [ ' Schema' ] ) => fs . exists ( asset . source ) . tap ( exist => {
1414 if ( ! exist ) return asset . remove ( ) ;
15- } ) ) . map ( ( asset : warehouse . Schema ) => {
15+ } ) ) . map ( ( asset : warehouse [ ' Schema' ] ) => {
1616 const { source } = asset ;
1717 let { path } = asset ;
1818 const data : Data = {
Original file line number Diff line number Diff line change @@ -6,6 +6,18 @@ const rCaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+)\s+(.+)/i;
66const rCaptionUrl = / ( \S [ \S \s ] * ) \s + ( h t t p s ? : \/ \/ \S + ) / i;
77const rCaption = / \S [ \S \s ] * / ;
88
9+ interface Options {
10+ lang : string ;
11+ language_attr : boolean ;
12+ firstLine : number ;
13+ caption : string ;
14+ line_number : boolean ;
15+ line_threshold : number ;
16+ mark : number [ ] ;
17+ wrap : boolean ;
18+ lines_length ?: number ;
19+ }
20+
921/**
1022 * Code block tag
1123 * Syntax:
@@ -25,7 +37,7 @@ const rCaption = /\S[\S\s]*/;
2537 * @returns {String } Code snippet with code highlighting
2638*/
2739
28- function parseArgs ( args ) {
40+ function parseArgs ( args ) : Options {
2941 const _else = [ ] ;
3042 const len = args . length ;
3143 let lang , language_attr ,
Original file line number Diff line number Diff line change 11import moize from 'moize' ;
22
3- export = ctx => {
3+ export default ctx => {
44 const { tag } = ctx . extend ;
55
66 const blockquote = require ( './blockquote' ) ( ctx ) ;
You can’t perform that action at this time.
0 commit comments