{"id":26367546,"url":"https://github.com/hashedalgorithm/loki","last_synced_at":"2025-03-16T21:17:41.500Z","repository":{"id":282314110,"uuid":"948171080","full_name":"hashedalgorithm/loki","owner":"hashedalgorithm","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-13T22:09:46.000Z","size":161,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T23:22:54.098Z","etag":null,"topics":[],"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/hashedalgorithm.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}},"created_at":"2025-03-13T21:43:10.000Z","updated_at":"2025-03-13T22:09:49.000Z","dependencies_parsed_at":"2025-03-14T00:00:45.826Z","dependency_job_id":null,"html_url":"https://github.com/hashedalgorithm/loki","commit_stats":null,"previous_names":["hashedalgorithm/loki"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashedalgorithm%2Floki","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashedalgorithm%2Floki/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashedalgorithm%2Floki/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hashedalgorithm%2Floki/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hashedalgorithm","download_url":"https://codeload.github.com/hashedalgorithm/loki/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933448,"owners_count":20370988,"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":[],"created_at":"2025-03-16T21:17:41.053Z","updated_at":"2025-03-16T21:17:41.488Z","avatar_url":"https://github.com/hashedalgorithm.png","language":"TypeScript","readme":"# Loki 🧩\n\nLoki is a lightweight React component designed to simplify the creation of inline text links with custom styles. It eliminates the need for manually nesting multiple `\u003cspan\u003e` and `\u003ca\u003e` tags, making it easier to create styled inline links in React and Next.js applications.\n\n## Features\n\n- **📚 Simplified Inline Links**: Easily create inline links from formatted strings without manually nesting tags.\n- **🎨 Customizable Styles**: Apply custom styles to links using the `linkClassName` prop.\n- **🔗 Flexible Link Targeting**: Configure the `target` attribute for links (e.g., `_blank`, `_self`).\n- **⚡ Lightweight and Fast**: Built with performance in mind, leveraging React's `useMemo` for efficient rendering.\n\n## Installation\n\nInstall Loki using npm or yarn:\n\n```bash\nnpm install loki\n```\n\n```bash\nyarn add loki\n```\n\n## Usage\n\nThe `TextInlineLink` component accepts a string as its `children` prop. The string should follow this format:\n\n```\nI agree to [Terms \u0026 Conditions](https://www.sample.com/terms)\n```\n\nThis will render the text `I agree to Terms \u0026 Conditions`, where `Terms \u0026 Conditions` is a hyperlink pointing to `https://www.sample.com/terms`.\n\n### Example\n\n```tsx\nimport { TextInlineLink } from 'loki';\n\nconst App = () =\u003e {\n  return (\n    \u003cTextInlineLink linkClassName=\"text-blue-500 underline\"\u003e\n      I agree to [Terms \u0026 Conditions](https://www.sample.com/terms)\n    \u003c/TextInlineLink\u003e\n  );\n};\n\nexport default App;\n```\n\n### Props\n\n| Prop            | Type     | Description                                                                 |\n| --------------- | -------- | --------------------------------------------------------------------------- |\n| `children`      | `string` | The input string containing text and links in the specified format.         |\n| `linkClassName` | `string` | Optional. Custom class name to style the link text.                         |\n| `target`        | `string` | Optional. Specifies the target attribute for the links (default: `_blank`). |\n\n## How It Works\n\nThe component parses the input string using a regular expression to identify patterns like `[label](link)`. It then replaces these patterns with the appropriate HTML structure, including `\u003cspan\u003e` and `\u003ca\u003e` tags, while applying the provided styles and attributes.\n\n### Input Example\n\n```text\nI agree to [Terms \u0026 Conditions](https://www.sample.com/terms)\n```\n\n### Output HTML\n\n```html\n\u003cp\u003e\n  I agree to\n  \u003cspan class=\"mx-1\"\u003e\n    \u003ca href=\"https://www.sample.com/terms\" target=\"_blank\"\u003e\n      \u003cspan class=\"underline text-blue-500\"\u003eTerms \u0026 Conditions\u003c/span\u003e\n    \u003c/a\u003e\n  \u003c/span\u003e\n\u003c/p\u003e\n```\n\n## Customization\n\nYou can customize the appearance of the links by passing a `linkClassName` prop. For example:\n\n```tsx\n\u003cTextInlineLink linkClassName=\"text-red-500 underline\"\u003e\n  Click [here](https://www.example.com) for more details.\n\u003c/TextInlineLink\u003e\n```\n\nThis will render the link with a red underline.\n\n## Limitations\n\n- The input string must follow the `[label](link)` format for links to be parsed correctly.\n- The component uses `dangerouslySetInnerHTML` to render the parsed HTML, so ensure the input string is sanitized if it comes from an untrusted source.\n\n## Issues\n\nIf you encounter any bugs or have suggestions for improvements, please [open an issue](https://github.com/hashedalgorithm/loki/issues).\n\n## Contributing\n\nContributions are welcome! Please refer to the [contribution guidelines](https://github.com/hashedalgorithm/loki/contributing) before getting started.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashedalgorithm%2Floki","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashedalgorithm%2Floki","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashedalgorithm%2Floki/lists"}