rehype-og-card 0.4.2 → 1.0.0
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 +7 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/util/hast.d.ts +1 -0
- package/dist/util/hast.js +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,6 +150,13 @@ Domains to exclude from conversion.
|
|
|
150
150
|
- Type: `"eager" | "lazy"`
|
|
151
151
|
- Default: `"lazy"`
|
|
152
152
|
|
|
153
|
+
### `openInNewTab`
|
|
154
|
+
|
|
155
|
+
Whether to open the link in a new tab.
|
|
156
|
+
|
|
157
|
+
- Type: `boolean`
|
|
158
|
+
- Default: `false`
|
|
159
|
+
|
|
153
160
|
### `serverCache`
|
|
154
161
|
|
|
155
162
|
Whether to cache the OG data on the server.
|
package/dist/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ interface RehypeOGCardOptions {
|
|
|
18
18
|
* @default true
|
|
19
19
|
*/
|
|
20
20
|
shortenURL?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to open the link in a new tab.
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
openInNewTab?: boolean;
|
|
21
26
|
/**
|
|
22
27
|
* Whether to enable converting the links
|
|
23
28
|
* that have the same URL and text (e.g., `[https://example.com](https://example.com)`).
|
package/dist/util/hast.d.ts
CHANGED
|
@@ -33,5 +33,6 @@ declare const convertTextToAnchorElement: (text: Text) => AnchorElement;
|
|
|
33
33
|
declare const createOGCard: (data: OGCardData, options: Required<{
|
|
34
34
|
loading: RehypeOGCardOptions["loading"];
|
|
35
35
|
decoding: RehypeOGCardOptions["decoding"];
|
|
36
|
+
openInNewTab: RehypeOGCardOptions["openInNewTab"];
|
|
36
37
|
}>) => Element;
|
|
37
38
|
export { AnchorElement, isTextNode, isAnchorElement, convertTextToAnchorElement, createOGCard };
|
package/dist/util/hast.js
CHANGED
|
@@ -32,8 +32,13 @@ const convertTextToAnchorElement = (text) => ({
|
|
|
32
32
|
* @returns OG card element.
|
|
33
33
|
*/
|
|
34
34
|
const createOGCard = (data, options) => {
|
|
35
|
+
const openInNewTab = {
|
|
36
|
+
rel: "noopener noreferrer",
|
|
37
|
+
target: "_blank"
|
|
38
|
+
};
|
|
35
39
|
const card = h("div.og-card-container", [
|
|
36
|
-
|
|
40
|
+
// eslint-disable-next-line no-extra-parens
|
|
41
|
+
h("a", Object.assign({ href: data.url }, (options.openInNewTab ? openInNewTab : {})), [
|
|
37
42
|
h("div.og-card-info", [
|
|
38
43
|
h("div.og-card-title", data.title),
|
|
39
44
|
data.description ? h("div.og-card-description", data.description) : null,
|