-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In useOgImage() hook adds searchParams option for setting arbitrary q…
…uery string vars to generated URL (#10677) Found a missing feature while working on adding og:image support to Cambium: Right now setting the width or height of an og:image will add those properties as query string variables in the URL that's generated: http://localhost:8910/photo.png?width=1000&height=800 But you may need variables that you'll use to modify the image you generate. We need a way to also add these to the final URL: http://localhost:8910/photo.png?brightness=0.8&contrast=1.5 I'm thinking of having useOgImage() accept an additional key in its object argument, which is an object containing all of the vars you want to append to the URL. This can be a simple object or an instance of URLSearchParams and we'll do the right thing: const { url } = useOgImage({ searchParams: { brightness: 0.9, contrast: 1.5 } }) // url => http://localhost:8910/photo.png?brightness=0.9&contrast=1.5
- Loading branch information
Showing
3 changed files
with
66 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- Adds `searchParams` option to `useOgImage()` hook for adding arbitrary query string vars to generated URL (#10677) by @cannikin | ||
|
||
``` | ||
const { url } = useOgImage({ searchParams: { foo: 'bar' }) | ||
console.log(url) // => http://localhost:8910/photo.png?foo=bar | ||
``` |
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