{"id":23973550,"url":"https://github.com/okaryo/remark-link-card-plus","last_synced_at":"2025-04-13T21:37:01.341Z","repository":{"id":271082107,"uuid":"910816390","full_name":"okaryo/remark-link-card-plus","owner":"okaryo","description":"Remark plugin to convert text links to link cards","archived":false,"fork":false,"pushed_at":"2025-04-12T03:45:44.000Z","size":681,"stargazers_count":10,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T04:34:22.052Z","etag":null,"topics":["card","link","markdown","remark","remark-plugin","unified"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/remark-link-card-plus","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okaryo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-01T14:18:28.000Z","updated_at":"2025-03-31T14:42:29.000Z","dependencies_parsed_at":"2025-01-05T11:28:28.236Z","dependency_job_id":"f00d7eeb-d6ff-4460-aabf-be1f7f2c6e2a","html_url":"https://github.com/okaryo/remark-link-card-plus","commit_stats":null,"previous_names":["okaryo/remark-link-card-plus"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaryo%2Fremark-link-card-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaryo%2Fremark-link-card-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaryo%2Fremark-link-card-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaryo%2Fremark-link-card-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okaryo","download_url":"https://codeload.github.com/okaryo/remark-link-card-plus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519106,"owners_count":21117756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["card","link","markdown","remark","remark-plugin","unified"],"created_at":"2025-01-07T04:59:32.861Z","updated_at":"2025-04-13T21:37:01.332Z","avatar_url":"https://github.com/okaryo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# remark-link-card-plus\n\n[![CI](https://github.com/okaryo/remark-link-card-plus/actions/workflows/ci.yml/badge.svg)](https://github.com/okaryo/remark-link-card-plus/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/remark-link-card-plus)](https://www.npmjs.com/package/remark-link-card-plus)\n\n[remark](https://github.com/remarkjs/remark) plugin to convert text links to link cards, building upon and improving [remark-link-card](https://github.com/gladevise/remark-link-card).\n\nYou can see it in action on the [demo page](https://remark-link-card-plus.pages.dev/).\n\n## Features\n\n`remark-link-card-plus` is a fork of the original `remark-link-card` with the following changes:\n\n### Differences from the original:\n* **TypeScript support**: Fully rewritten in TypeScript for improved type safety and developer experience.\n* **Target blank**: Links in link cards now open in a new tab using `target=\"_blank\"`.\n* **No link cards in lists**: Links inside list items (`listItem`) are not converted into link cards.\n* **Thumbnail position customization**: Select whether the thumbnail is displayed on the left or right of the card.\n* **Optional image and favicon display**: Added `noThumbnail` and `noFavicon` options to hide thumbnails and favicons from link cards.\n* **OG data transformer**: The `ogTransformer` option allows customization of Open Graph data such as the title, description, favicon, and image before rendering the link card.\n\n### Retained features:\n* **Options support**:\n  * `cache`: Cache images for faster loading and local storage.\n  * `shortenUrl`: Display only the hostname of URLs in link cards.\n* **Customizable styling**: Cards can be styled freely using provided class names (note that class names have been slightly updated).\n\n## Install\n\n```sh\nnpm i remark-link-card-plus\n```\n\n## Usage\n\n### Basic Example\n\n```js\nimport { remark } from \"remark\";\nimport remarkLinkCard from \"remark-link-card-plus\";\n\nconst exampleMarkdown = `\n# Example Markdown\n\n## Link Card Demo\n\nBare links like this:\n\nhttps://github.com\n\nwill be converted into a link card.\n\nInline links like [GitHub](https://github.com) will **not** be converted.\n`;\n\n(async () =\u003e {\n  const result = await remark()\n    .use(remarkLinkCard, { cache: true, shortenUrl: true })\n    .process(exampleMarkdown);\n\n  console.log(result.value);\n})();\n```\n\nYou can get converted result like this.\n\n```md\n# Example Markdown\n\n## Link Card Demo\n\nBare links like this:\n\n\u003cdiv class=\"remark-link-card-plus__container\"\u003e\n  \u003ca href=\"https://github.com/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"remark-link-card-plus__card\"\u003e\n    \u003cdiv class=\"remark-link-card-plus__main\"\u003e\n      \u003cdiv class=\"remark-link-card-plus__content\"\u003e\n        \u003cdiv class=\"remark-link-card-plus__title\"\u003eGitHub · Build and ship software on a single, collaborative platform\u003c/div\u003e\n        \u003cdiv class=\"remark-link-card-plus__description\"\u003eJoin the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.\u003c/div\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"remark-link-card-plus__meta\"\u003e\n        \u003cimg src=\"https://www.google.com/s2/favicons?domain=github.com\" class=\"remark-link-card-plus__favicon\" width=\"14\" height=\"14\" alt=\"favicon\"\u003e\n        \u003cspan class=\"remark-link-card-plus__url\"\u003egithub.com\u003c/span\u003e\n      \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"remark-link-card-plus__thumbnail\"\u003e\n      \u003cimg src=\"https://github.githubassets.com/assets/home24-5939032587c9.jpg\" class=\"remark-link-card-plus__image\" alt=\"ogImage\"\u003e\n    \u003c/div\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\nwill be converted into a link card.\n\nInline links like [GitHub](https://github.com) will **not** be converted.\n```\n\n### Astro Example\n\nYou can also use `remark-link-card-plus` in an [Astro](https://astro.build) project. Below is an example `astro.config.mjs` configuration:\n\n```javascript\n// astro.config.mjs\nimport { defineConfig } from 'astro/config';\nimport remarkLinkCard from 'remark-link-card-plus';\n\nexport default defineConfig({\n  markdown: {\n    remarkPlugins: [\n      [\n        remarkLinkCard, {\n          cache: true,\n          shortenUrl: true,\n          thumbnailPosition: \"right\",\n          noThumbnail: false,\n          noFavicon: false,\n          ogTransformer: (og) =\u003e {\n            if (og.title === og.description) {\n              return { ...og, description: 'custom description' };\n            }\n            return og;\n          }\n        },\n      ],\n    ],\n  },\n});\n\n// Here is minimal setup.\nexport default defineConfig({\n  markdown: {\n    remarkPlugins: [remarkLinkCard],\n  },\n});\n```\n\n## Options\n\n| Option       | Type    | Default | Description                                                                 |\n|--------------|---------|---------|-----------------------------------------------------------------------------|\n| `cache`      | boolean | `false` | Caches Open Graph images and favicons locally. Images are saved to `process.cwd()/public/remark-link-card-plus/` and paths start with `/remark-link-card-plus/`. This reduces server load on the linked site and improves build performance by avoiding redundant network requests. |\n| `shortenUrl` | boolean | `true`  | Displays only the hostname of the URL in the link card instead of the full URL. |\n| `thumbnailPosition` | string | `right`  | Specifies the position of the thumbnail in the card. Accepts `\"left\"` or `\"right\"`. |\n| `noThumbnail` | boolean | `false` | If `true`, does not display the Open Graph thumbnail image. The generated link card HTML will not contain an `\u003cimg\u003e` tag for the thumbnail. |\n| `noFavicon`   | boolean | `false` | If `true`, does not display the favicon in the link card. The generated link card HTML will not contain an `\u003cimg\u003e` tag for the favicon. |\n| `ogTransformer` | `(og: OgData) =\u003e OgData` | `undefined` | A callback to transform the Open Graph data before rendering. `OgData` has the structure `{ title: string; description: string; faviconUrl?: string; imageUrl?: string }`. |\n\n## Styling\n\nLink cards can be styled using the following class names:\n\n```css\n.remark-link-card-plus__container {}\n\n.remark-link-card-plus__card {}\n\n.remark-link-card-plus__main {}\n\n.remark-link-card-plus__content {}\n\n.remark-link-card-plus__title {}\n\n.remark-link-card-plus__description {}\n\n.remark-link-card-plus__meta {}\n\n.remark-link-card-plus__favicon {}\n\n.remark-link-card-plus__url {}\n\n.remark-link-card-plus__thumbnail {}\n\n.remark-link-card-plus__image {}\n```\n\nFeel free to customize these styles as needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokaryo%2Fremark-link-card-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokaryo%2Fremark-link-card-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokaryo%2Fremark-link-card-plus/lists"}