forked from hexojs/site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hexojs#1485 from curbengh/injector-bind-2
docs(injector): helper must bind to hexo context
- Loading branch information
Showing
7 changed files
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ There are other internal functions, see [hexojs/hexo#4049](https://github.com/he | |
## Example | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -62,15 +62,14 @@ hexo.extend.injector.register('body_end', () => { | |
|
||
Above setup will inject `APlayer.min.css` (`<link>` tag) to the `</head>` of any page which layout is `music`, and `APlayer.min.js` (`<script>` tag) to the `</body>` of those pages. Also, `jquery.js` (`<script>` tag) will be injected to `</body>` of every page generated. | ||
|
||
|
||
## Accessing user configuration | ||
|
||
Use any of the following options: | ||
|
||
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -115,14 +114,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ There are other internal functions, see [hexojs/hexo#4049](https://github.com/he | |
## Example | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -69,7 +69,7 @@ Use any of the following options: | |
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -114,14 +114,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ There are other internal functions, see [hexojs/hexo#4049](https://github.com/he | |
## Example | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -69,7 +69,7 @@ Use any of the following options: | |
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -114,14 +114,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ There are other internal functions, see [hexojs/hexo#4049](https://github.com/he | |
## Example | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -69,7 +69,7 @@ Use any of the following options: | |
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -114,14 +114,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ There are other internal functions, see [hexojs/hexo#4049](https://github.com/he | |
## Example | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -69,7 +69,7 @@ Use any of the following options: | |
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -114,14 +114,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,8 @@ hexo.extend.injector.register(entry, value, to) | |
## 样例 | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -67,7 +67,7 @@ Use any of the following options: | |
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -112,14 +112,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,8 @@ There are other internal functions, see [hexojs/hexo#4049](https://github.com/he | |
## Example | ||
|
||
```js | ||
const css = hexo.extend.helper.get('css'); | ||
const js = hexo.extend.helper.get('js'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const js = hexo.extend.helper.get('js').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
return css('https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css'); | ||
|
@@ -69,7 +69,7 @@ Use any of the following options: | |
1. | ||
|
||
``` js | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
|
||
hexo.extend.injector.register('head_end', () => { | ||
const { cssPath } = hexo.config.fooPlugin; | ||
|
@@ -114,14 +114,15 @@ hexo.extend.injector.register('head_end', require('./lib/inject')(hexo)) | |
|
||
``` js lib/inject.js | ||
module.exports = (hexo) => () => { | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
``` | ||
|
||
``` js lib/inject.js | ||
const injectFn = (hexo) => { | ||
const css = hexo.extend.helper.get('css'); | ||
const css = hexo.extend.helper.get('css').bind(hexo); | ||
const { cssPath } = hexo.config.fooPlugin; | ||
return css(cssPath); | ||
}; | ||
|