rehype-og-card 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/util/network.js +2 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ Expiration is calculated using the cached timestamp stored in the cache itself.
|
|
|
128
128
|
User agent to use for fetching the OG metadata and images.
|
|
129
129
|
|
|
130
130
|
- Type: `string`
|
|
131
|
-
- Default: `"Mozilla/5.0 (
|
|
131
|
+
- Default: `"Mozilla/5.0 (compatible; rehype-og-card/2.0; +https://github.com/Robot-Inventor/rehype-og-card/; purpose=link-preview; twitterbot-compatible)"`
|
|
132
132
|
|
|
133
133
|
### `decoding`
|
|
134
134
|
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const DEFAULT_OPTIONS = {
|
|
|
13
13
|
buildCache: false,
|
|
14
14
|
buildCacheMaxAge: DEFAULT_CACHE_MAX_AGE_MS,
|
|
15
15
|
buildCachePath: "./node_modules/.cache",
|
|
16
|
-
crawlerUserAgent: "Mozilla/5.0 (
|
|
16
|
+
crawlerUserAgent: "Mozilla/5.0 (compatible; rehype-og-card/2.0; +https://github.com/Robot-Inventor/rehype-og-card/; purpose=link-preview; twitterbot-compatible)",
|
|
17
17
|
decoding: "async",
|
|
18
18
|
enableSameTextURLConversion: false,
|
|
19
19
|
excludeDomains: [],
|
package/dist/types.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ interface RehypeOGCardOptions {
|
|
|
69
69
|
buildCacheMaxAge?: number | false;
|
|
70
70
|
/**
|
|
71
71
|
* User agent to use for fetching the OG metadata and images.
|
|
72
|
-
* @default "Mozilla/5.0 (
|
|
72
|
+
* @default "Mozilla/5.0 (compatible; rehype-og-card/2.0; +https://github.com/Robot-Inventor/rehype-og-card/; purpose=link-preview; twitterbot-compatible)"
|
|
73
73
|
*/
|
|
74
74
|
crawlerUserAgent?: string;
|
|
75
75
|
}
|
package/dist/util/network.js
CHANGED
|
@@ -46,10 +46,8 @@ const getOGData = async (url, userAgent) => {
|
|
|
46
46
|
});
|
|
47
47
|
const OGImage = result.ogImage ? result.ogImage[0] : null;
|
|
48
48
|
const OGImageURL = resolveAbsoluteURL(OGImage?.url, url);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
: // eslint-disable-next-line no-undefined
|
|
52
|
-
undefined;
|
|
49
|
+
const resolvedFaviconURL = result.favicon ? resolveAbsoluteURL(result.favicon, url) : null;
|
|
50
|
+
const faviconURL = resolvedFaviconURL ?? `https://www.google.com/s2/favicons?domain=${new URL(url).hostname}`;
|
|
53
51
|
return {
|
|
54
52
|
OGImageAlt: OGImage?.alt,
|
|
55
53
|
OGImageHeight: OGImage?.height,
|