{"id":19529907,"url":"https://github.com/loopmode/use-content","last_synced_at":"2025-02-26T02:43:13.409Z","repository":{"id":140400283,"uuid":"178024740","full_name":"loopmode/use-content","owner":"loopmode","description":"A react hook for using local or remote string-based content","archived":false,"fork":false,"pushed_at":"2019-03-27T15:37:52.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T18:37:06.216Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loopmode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2019-03-27T15:37:21.000Z","updated_at":"2019-03-27T15:37:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"21e68745-a747-4eeb-92fd-0f7f2c1251b0","html_url":"https://github.com/loopmode/use-content","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Fuse-content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Fuse-content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Fuse-content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loopmode%2Fuse-content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loopmode","download_url":"https://codeload.github.com/loopmode/use-content/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240783109,"owners_count":19856776,"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":"2024-11-11T01:28:05.362Z","updated_at":"2025-02-26T02:43:13.344Z","avatar_url":"https://github.com/loopmode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @loopmode/use-content\n\nA react effect hook for displaying local or remote string-based content.\n\n## Usage\n\n```jsx\n\nimport React from 'react';\nimport useContent from '@loopmode/use-content';\n\nconst Content = ({ children, src }) =\u003e {\n    const content = useContent(children, { src });\n    return (\n        \u003cdiv\u003e{content}\u003c/div\u003e\n    );\n}\n\nconst Demo = () =\u003e {\n    return (\n        \u003cdiv\u003e\n            \u003cContent\u003eHello text!\u003c/Content\u003e\n            \u003cContent src=\"https://raw.githubusercontent.com/git/git/master/README.md\" /\u003e\n        \u003c/div\u003e\n    );\n}\n\n```\n\nIf a `src` is provided, the content is loaded from that URL.\nThe default setup uses `window.fetch` for loading and aborts pending requests when the component gets unmounted.\n\nIf a `redact` function is provided, it is invoked with the current content and its return value becomes the new value.\n\nIf an `append` or `prepend` value is provided, it will be resolved to a string value.\n\n```jsx\nimport React from 'react';\nimport useContent from '@loopmode/use-content';\n\n\nconst addSrc = ({ src }) =\u003e `// src: ${src}`;\nconst addMeta = props =\u003e `/*\\n${JSON.stringify(props, replacer, 4)}\\n*/`;\n\nconst Content = ({ children, src }) =\u003e {\n    const content = useContent(children, {\n        src,\n        prepend: [addSrc, `// Copyright foo`, props =\u003e !!props.content \u0026\u0026 'Loading...'],\n        append: addMeta\n    });\n    return (\n        \u003cdiv\u003e{content}\u003c/div\u003e\n    );\n}\nconst Demo = () =\u003e {\n    return (\n        \u003cContent src=\"https://raw.githubusercontent.com/git/git/master/README.md\" /\u003e\n    );\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopmode%2Fuse-content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floopmode%2Fuse-content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floopmode%2Fuse-content/lists"}