Skip to content

Commit 137b2f4

Browse files
rista404Kikobeats
authored andcommitted
Add greyscale option to Clearbit logo API (#110)
1 parent 4ddd209 commit 137b2f4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/metascraper-clearbit-logo/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Default: `png`
3131

3232
Image format, either "png" or "jpg".
3333

34+
##### greyscale
35+
36+
Type: `boolean`<br>
37+
Default: `false`
38+
39+
Desaturates image if set to `true`.
40+
3441
## License
3542

3643
**metascraper-clearbit-logo** © [microlink.io](https://microlink.io), Released under the [MIT](https://github.com/microlinkhq/metascraper-clearbit-logo/blob/master/LICENSE.md) License.<br>

packages/metascraper-clearbit-logo/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ const got = require('got')
55

66
const DEFAULTS = {
77
size: '128',
8-
format: 'png'
8+
format: 'png',
9+
greyscale: false
910
}
1011

1112
const ENDPOINT = 'https://logo.clearbit.com'
1213

1314
module.exports = opts => {
1415
opts = Object.assign({}, DEFAULTS, opts)
15-
const { size, format } = opts
16+
const { size, format, greyscale } = opts
1617

1718
const clearbitLogo = async ({ url }) => {
1819
const { hostname } = new URL(url)
19-
const logoUrl = `${ENDPOINT}/${hostname}?size=${size}&format=${format}`
20+
const logoUrl = `${ENDPOINT}/${hostname}?size=${size}&format=${format}${
21+
greyscale ? '&greyscale=true' : ''
22+
}`
2023

2124
try {
2225
await got.head(logoUrl)

0 commit comments

Comments
 (0)