-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
28 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
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 |
---|---|---|
|
@@ -9,5 +9,6 @@ | |
"author": "", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"unist-builder": "^4.0.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
const unsplashDirective = { | ||
name: 'unsplash', | ||
doc: 'An example directive for showing a nice random image at a custom size.', | ||
alias: ['random-pic'], | ||
arg: { type: String, doc: 'The kinds of images to search for, e.g., `fruit`' }, | ||
name: "unsplash", | ||
doc: "An example directive for showing a nice random image at a custom size.", | ||
alias: ["random-pic"], | ||
arg: { | ||
type: String, | ||
doc: "The kinds of images to search for, e.g., `fruit`", | ||
}, | ||
options: { | ||
size: { type: String, doc: 'Size of the image, for example, `500x200`.' }, | ||
size: { type: String, doc: "Size of the image, for example, `500x200`." }, | ||
}, | ||
run(data) { | ||
console.log(data) | ||
console.log("unsplash data", data); | ||
const query = data.arg; | ||
const size = data.options.size || '500x200'; | ||
const size = data.options.size || "500x200"; | ||
const url = `https://source.unsplash.com/random/${size}/?${query}`; | ||
const img = { type: 'image', url }; | ||
const img = { type: "image", url }; | ||
return [img]; | ||
}, | ||
}; | ||
|
||
const plugin = { name: 'Unsplash Images', directives: [unsplashDirective] }; | ||
const plugin = { name: "Unsplash Images", directives: [unsplashDirective] }; | ||
|
||
export default plugin; |