-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use picsum instead of unsplash (#1660)
- Loading branch information
Showing
6 changed files
with
68 additions
and
46 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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const picsumDirective = { | ||
name: 'picsum', | ||
doc: 'An example directive for showing a nice random image at a custom size.', | ||
alias: ['random-pic'], | ||
arg: { | ||
type: String, | ||
doc: 'The ID of the image to use, e.g. 1', | ||
}, | ||
options: { | ||
size: { type: String, doc: 'Size of the image, for example, `500x200`.' }, | ||
}, | ||
run(data) { | ||
// Parse size | ||
const match = (data.options?.size ?? '').match(/^(\d+)(?:x(\d+))?$/); | ||
let sizeQuery = '200/200'; | ||
if (match) { | ||
const first = match[1]; | ||
const second = match[2]; | ||
sizeQuery = second ? `${first}/${second}` : first; | ||
} | ||
|
||
const idQuery = data.arg ? `id/${data.arg}/` : ''; | ||
const url = `https://picsum.photos/${idQuery}${sizeQuery}`; | ||
const img = { type: 'image', url }; | ||
return [img]; | ||
}, | ||
}; | ||
|
||
const plugin = { name: 'Lorem Picsum Images', directives: [picsumDirective] }; | ||
|
||
export default plugin; |
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 was deleted.
Oops, something went wrong.