{"id":29028425,"url":"https://github.com/suin/auto-page-card","last_synced_at":"2026-01-20T16:57:55.793Z","repository":{"id":300984039,"uuid":"1007798144","full_name":"suin/auto-page-card","owner":"suin","description":"A remark plugin that automatically transforms local MDX links into customizable page card components","archived":false,"fork":false,"pushed_at":"2025-06-24T14:47:40.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-24T15:45:52.931Z","etag":null,"topics":["astro","documentation","gatsby","link-transformation","markdown","mdx","nextjs","page-card","remark","remark-plugin","static-site","typescript","unified"],"latest_commit_sha":null,"homepage":null,"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/suin.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-06-24T14:43:42.000Z","updated_at":"2025-06-24T14:47:44.000Z","dependencies_parsed_at":"2025-06-24T15:45:55.431Z","dependency_job_id":"25efd5be-2530-43bf-88d0-3056183e7121","html_url":"https://github.com/suin/auto-page-card","commit_stats":null,"previous_names":["suin/auto-page-card"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/suin/auto-page-card","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suin%2Fauto-page-card","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suin%2Fauto-page-card/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suin%2Fauto-page-card/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suin%2Fauto-page-card/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suin","download_url":"https://codeload.github.com/suin/auto-page-card/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suin%2Fauto-page-card/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261896992,"owners_count":23226646,"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":["astro","documentation","gatsby","link-transformation","markdown","mdx","nextjs","page-card","remark","remark-plugin","static-site","typescript","unified"],"created_at":"2025-06-26T07:11:22.864Z","updated_at":"2026-01-20T16:57:55.787Z","avatar_url":"https://github.com/suin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @suin/auto-page-card\n\n\u003e A remark plugin that automatically transforms local MDX links into customizable page card components\n\n[![npm version](https://img.shields.io/npm/v/@suin/auto-page-card.svg)](https://www.npmjs.com/package/@suin/auto-page-card)\n[![npm downloads](https://img.shields.io/npm/dm/@suin/auto-page-card.svg)](https://www.npmjs.com/package/@suin/auto-page-card)\n[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/suin/auto-page-card/actions/workflows/ci.yml/badge.svg)](https://github.com/suin/auto-page-card/actions/workflows/ci.yml)\n[![Publish](https://github.com/suin/auto-page-card/actions/workflows/publish.yml/badge.svg)](https://github.com/suin/auto-page-card/actions/workflows/publish.yml)\n\n## 🚀 Features\n\n- **Automatic Transformation**: Converts local MDX links to page card components automatically\n- **Fumadocs Integration**: Fully compatible with [@suin/fumadocs-page-card](https://github.com/suin/fumadocs-page-card) out of the box\n- **Smart Detection**: Only transforms links that point to local `.mdx` files\n- **Customizable**: Supports custom component names and attributes\n- **TypeScript Ready**: Full TypeScript support with comprehensive type definitions\n- **Zero Dependencies**: Lightweight with no runtime dependencies\n- **MDX Compatible**: Works seamlessly with MDX and remark ecosystem\n\n## 📦 Installation\n\n```bash\nnpm install @suin/auto-page-card\n```\n\nOr using yarn:\n\n```bash\nyarn add @suin/auto-page-card\n```\n\nOr using bun:\n\n```bash\nbun add @suin/auto-page-card\n```\n\n## ⚠️ Important: Required Component\n\n**This package transforms markdown links into `\u003cPageCard\u003e` components by default.** You'll need to provide the actual PageCard component in your MDX setup. We strongly recommend using **[@suin/fumadocs-page-card](https://github.com/suin/fumadocs-page-card)** - a React component that renders beautiful page cards with automatic metadata extraction from MDX frontmatter.\n\n```bash\nnpm install @suin/fumadocs-page-card\n```\n\n## 🎯 Usage\n\n### Basic Usage\n\n```javascript\nimport { unified } from \"unified\";\nimport remarkParse from \"remark-parse\";\nimport remarkMdx from \"remark-mdx\";\nimport remarkAutoPageCard from \"@suin/auto-page-card\";\nimport remarkStringify from \"remark-stringify\";\n\nconst processor = unified()\n  .use(remarkParse)\n  .use(remarkMdx)\n  .use(remarkAutoPageCard)\n  .use(remarkStringify);\n\nconst result = await processor.process(`\n# My Documentation\n\n[Getting Started](./getting-started.mdx)\n\n[Advanced Topics](../docs/advanced.mdx)\n`);\n```\n\n### With Custom Component\n\n```javascript\nimport remarkAutoPageCard from \"@suin/auto-page-card\";\n\nconst processor = unified()\n  .use(remarkParse)\n  .use(remarkMdx)\n  .use(remarkAutoPageCard, {\n    element: {\n      name: \"CustomCard\",\n      attributes: ({ url }) =\u003e ({\n        href: url,\n        className: \"my-custom-card\",\n        showPreview: true,\n      }),\n    },\n  })\n  .use(remarkStringify);\n```\n\n## 🔧 API\n\n### `remarkAutoPageCard(options?)`\n\nThe main plugin function that transforms local MDX links into page card components.\n\n#### Options\n\n| Option    | Type                   | Default          | Description                  |\n| --------- | ---------------------- | ---------------- | ---------------------------- |\n| `element` | `Element \\| undefined` | `defaultElement` | Custom element configuration |\n\n#### Element Configuration\n\n```typescript\ninterface Element {\n  readonly name: string;\n  readonly attributes: (link: { url: string }) =\u003e Attributes;\n}\n\ntype Attributes = Readonly\u003cRecord\u003cstring, null | boolean | number | string\u003e\u003e;\n```\n\n- `name`: The component name to use (e.g., `'PageCard'`, `'CustomCard'`)\n- `attributes`: A function that returns the attributes object for the component\n\n### Default Behavior\n\nBy default, the plugin transforms links like this:\n\n**Input:**\n\n```markdown\n[Getting Started](./getting-started.mdx)\n```\n\n**Output:**\n\n```jsx\n\u003cPageCard href=\"./getting-started.mdx\" /\u003e\n```\n\n## 📝 Examples\n\n### Example 1: Basic Transformation\n\n**Input:**\n\n```markdown\n# Documentation\n\n[Installation Guide](./installation.mdx)\n\n[API Reference](../docs/api.mdx)\n```\n\n**Output:**\n\n```jsx\n\u003ch1\u003eDocumentation\u003c/h1\u003e\n\n\u003cPageCard href=\"./installation.mdx\" /\u003e\n\n\u003cPageCard href=\"../docs/api.mdx\" /\u003e\n```\n\n### Example 2: Custom Component with Rich Attributes\n\n```javascript\n.use(remarkAutoPageCard, {\n  element: {\n    name: 'DocumentationCard',\n    attributes: ({ url }) =\u003e ({\n      href: url,\n      className: 'doc-card',\n      showMetadata: true,\n      layout: 'horizontal'\n    })\n  }\n})\n```\n\n**Input:**\n\n```markdown\n[User Guide](./user-guide.mdx)\n```\n\n**Output:**\n\n```jsx\n\u003cDocumentationCard\n  href=\"./user-guide.mdx\"\n  className=\"doc-card\"\n  showMetadata={true}\n  layout=\"horizontal\"\n/\u003e\n```\n\n### Example 3: Integration with Next.js\n\n```javascript\n// next.config.mjs\nimport remarkAutoPageCard from \"@suin/auto-page-card\";\nimport createMDX from \"@next/mdx\";\n\nconst withMDX = createMDX({\n  options: {\n    remarkPlugins: [\n      [\n        remarkAutoPageCard,\n        {\n          element: {\n            name: \"PageCard\",\n            attributes: ({ url }) =\u003e ({\n              href: url,\n              className: \"page-card\",\n            }),\n          },\n        },\n      ],\n    ],\n  },\n});\n\nexport default withMDX({\n  pageExtensions: [\"js\", \"jsx\", \"mdx\"],\n});\n```\n\n## 🎨 What Gets Transformed\n\nThe plugin only transforms paragraphs that contain:\n\n- A single link element\n- Links that point to local paths (starting with `./` or `../`)\n- Links that point to `.mdx` files\n\n### ✅ Will Transform\n\n```markdown\n[Page Title](./page.mdx)\n[Documentation](../docs/guide.mdx)\n```\n\n### ❌ Won't Transform\n\n```markdown\n[External Link](https://example.com)\n[Markdown File](./file.md)\n[Page Title](./page.mdx) with additional text\n```\n\n## 🤝 Contributing\n\nWe welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n### Development Setup\n\nThis project uses [Devbox](https://www.jetpack.io/devbox/) for consistent development environments. Devbox automatically installs and manages all the necessary tools and dependencies.\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/suin/auto-page-card.git\ncd auto-page-card\n```\n\n2. Install Devbox (if not already installed):\n\n```bash\ncurl -fsSL https://get.jetpack.io/devbox | bash\n```\n\n3. Start the development environment:\n\n```bash\ndevbox shell\n```\n\n4. Install dependencies:\n\n```bash\nbun install\n```\n\n5. Build the project:\n\n```bash\nbun run build\n```\n\n6. Run tests:\n\n```bash\nbun test\n```\n\n### Code Style\n\nThis project uses:\n\n- [Biome](https://biomejs.dev/) for code formatting and linting\n- [TypeScript](https://www.typescriptlang.org/) for type safety\n- [Bun](https://bun.sh/) for testing and package management\n- [Devbox](https://www.jetpack.io/devbox/) for development environment management\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Built with [unified](https://unifiedjs.com/) and [remark](https://remark.js.org/)\n- Inspired by the need for automatic page card generation in documentation sites\n- Thanks to the MDX and remark communities for their excellent tooling\n\n## 📞 Support\n\n- 📧 **Issues**: [GitHub Issues](https://github.com/suin/auto-page-card/issues)\n- 🐛 **Bugs**: Please report bugs on GitHub\n- 💡 **Feature Requests**: Open an issue to discuss new features\n- 📖 **Documentation**: Check the examples above or open an issue for clarification\n\n---\n\nMade with ❤️ by [suin](https://github.com/suin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuin%2Fauto-page-card","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuin%2Fauto-page-card","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuin%2Fauto-page-card/lists"}