{"id":16884383,"url":"https://github.com/tornqvist/prismic-element","last_synced_at":"2025-04-11T12:24:07.946Z","repository":{"id":57330624,"uuid":"90489308","full_name":"tornqvist/prismic-element","owner":"tornqvist","description":"Render Prismic.io fragments as DOM elements","archived":false,"fork":false,"pushed_at":"2022-01-07T16:58:00.000Z","size":94,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T08:42:46.242Z","etag":null,"topics":["bell","choo","dom-element","html","prismic"],"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/tornqvist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-06T20:28:20.000Z","updated_at":"2024-08-30T01:57:24.000Z","dependencies_parsed_at":"2022-09-26T16:31:18.181Z","dependency_job_id":null,"html_url":"https://github.com/tornqvist/prismic-element","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tornqvist%2Fprismic-element","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tornqvist%2Fprismic-element/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tornqvist%2Fprismic-element/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tornqvist%2Fprismic-element/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tornqvist","download_url":"https://codeload.github.com/tornqvist/prismic-element/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312131,"owners_count":21082638,"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":["bell","choo","dom-element","html","prismic"],"created_at":"2024-10-13T16:27:43.737Z","updated_at":"2025-04-11T12:24:07.923Z","avatar_url":"https://github.com/tornqvist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prismic-element\n\n[![npm version](https://img.shields.io/npm/v/prismic-element.svg?style=flat-square)](https://npmjs.org/package/prismic-element) [![downloads](http://img.shields.io/npm/dm/prismic-element.svg?style=flat-square)](https://npmjs.org/package/prismic-element)\n[![style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://npmjs.org/package/prismic-element)\n\nMimics [prismic-dom](https://github.com/prismicio/prismic-dom) except that it renders _real_ DOM nodes and not just HTML strings.\n\n*NOTE:*\n\nRequires version 2 of the Prismic.io API and the compatible JavaScript library [prismic-javascript](https://github.com/prismicio/prismic-javascript).\n\n## Usage\n\nPass a rich text object to the function and get HTML Element(s) back.\n\n```javascript\nconst Prismic = require('prismic-javascript')\nconst asElement = require('prismic-element')\n\nPrismic.api('https://\u003cYOUR_API_ENDPOINT\u003e.cdn.prismic.io/api').then(api =\u003e {\n  api.getSingle('my-page').then(doc =\u003e {\n    document.body.appendChild(asElement(doc.data.body));\n  })\n})\n```\n\n## With bel\n\nWorking with DOM elements integrates beautifully with tools such as [bel](https://github.com/shama/bel) and [choo](https://github.com/yoshuawuyts/choo).\n\n```javascript\nconst html = require('bel')\nconst Prismic = require('prismic-javascript')\nconst asElement = require('prismic-element')\n\nPrismic.api('https://\u003cYOUR_API_ENDPOINT\u003e.cdn.prismic.io/api').then(api =\u003e {\n  api.getSingle('my-page').then(doc =\u003e {\n    document.body.appendChild(html`\n      \u003carticle\u003e\n        ${asElement(doc.data.title)}\n\n        \u003cfigure\u003e\n          ${asElement(doc.data.image)}\n          \u003cfigcaption\u003e${doc.data.image.alt}\u003c/figcaption\u003e\n        \u003c/figure\u003e\n\n        \u003chr /\u003e\n\n        ${asElement(doc.data.body)}\n      \u003c/article\u003e\n    `)\n  })\n})\n```\n\n## See also\n- [Prismic.io](https://prismic.io) – CMS as a service\n- [bel](https://github.com/shama/bel) – Create DOM elements using tagged templates\n- [choo](https://github.com/yoshuawuyts/choo) - High level framework using tagged templates\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftornqvist%2Fprismic-element","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftornqvist%2Fprismic-element","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftornqvist%2Fprismic-element/lists"}