Skip to content

Commit

Permalink
Merge pull request #8 from qonto/update-readme
Browse files Browse the repository at this point in the history
doc: more readable
  • Loading branch information
mrloop authored May 19, 2021
2 parents c839e62 + 45810eb commit d9811c3
Showing 1 changed file with 45 additions and 24 deletions.
69 changes: 45 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ ember-prismic-dom
[npm-badge]: https://img.shields.io/npm/v/ember-prismic-dom.svg
[npm-badge-url]: https://www.npmjs.com/package/ember-prismic-dom

More idiomatic ember rendering of data from [Prismic](https://prismic.io/), generating HTML in templates. This allows you to avoid using of [triple curlies](https://handlebarsjs.com/guide/#html-escaping) to output [Prismic](https://prismic.io/) content.
Easy [Prismic](https://prismic.io/) rendering in [Ember.js](https://emberjs.com).

```hbs
<Prismic::Dom @nodes={{@prismicData}} />
```

Compatibility
------------------------------------------------------------------------------
Expand All @@ -22,33 +25,14 @@ Compatibility
Installation
------------------------------------------------------------------------------

```
```sh
ember install ember-prismic-dom
```


Usage
------------------------------------------------------------------------------

`<Primcic::Dom/>` replaces [`prismic-dom`](https://github.com/prismicio/prismic-dom)

In place of:
```js
import Component from '@glimmer/component';
import PrismicDOM from 'prismic-dom';

export default class MyComponent extends Component {
get html() {
return PrismicDOM.RichText.asHtml(this.args.myPrismicDoc.data.myRichText)
}
}
```

```hbs
{{{this.html}}}
```

Use this:
```hbs
<Prismic::Dom @nodes={{@myPrismicDoc.data.myRichText}} />
```
Expand All @@ -75,7 +59,7 @@ export default class MyComponent extends Component {

### Custom Rendering

Pass a custom component name to be used to render a prismic type. For example to custom render the 'group-list-item' and 'hyperlink' types
Pass a custom component name to be used to render a prismic type. For example to custom render the `group-list-item` and `hyperlink` types

```hbs
<Prismic::Dom
Expand All @@ -85,17 +69,54 @@ Pass a custom component name to be used to render a prismic type. For example to
/>
```

my-list.hbs
_my-list.hbs_
```hbs
<h1>My List</h2>
<ul>{{yield}}<ul>
```

my-hyperlink.hbs
_my-hyperlink.hbs_
```hbs
<a href={{@node.element.data.url}}>{{yield}}</a>
```

### Use existing addons

For example you want to use [`ember-async-image`](https://github.com/html-next/ember-async-image)

```hbs
<Prismic::Dom @nodes={{@nodes}} @image='image'>
```

_image.hbs_
```hbs
<AsyncImage src={{@node.element.url}}/>
```

### Migrating from prismic-dom

`<Primcic::Dom/>` replaces [`prismic-dom`](https://github.com/prismicio/prismic-dom) , please [see the blog post for more information.](https://medium.com/qonto-way/introducing-ember-prismic-dom-c362647037d7)

In place of:
```js
import Component from '@glimmer/component';
import PrismicDOM from 'prismic-dom';

export default class MyComponent extends Component {
get html() {
return PrismicDOM.RichText.asHtml(this.args.myPrismicDoc.data.myRichText)
}
}
```

```hbs
{{{this.html}}}
```

Use this:
```hbs
<Prismic::Dom @nodes={{@myPrismicDoc.data.myRichText}} />
```

Contributing
------------------------------------------------------------------------------
Expand Down

0 comments on commit d9811c3

Please sign in to comment.