Skip to content

Commit

Permalink
Merge pull request #22 from BKWLD/add-sanity-demo
Browse files Browse the repository at this point in the history
Add Sanity demo
  • Loading branch information
weotch authored Nov 15, 2023
2 parents 67c8746 + e5112fc commit f51b999
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
5 changes: 4 additions & 1 deletion adapters/globals/sanity-visual.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CloakVisual from '@cloak-app/visual/components/visual'
import CloakVisual from '../../components/visual'
export default {
functional: true,

Expand All @@ -24,6 +24,9 @@ export default {
props: {
...props,

// The provider should default Sanity
provider: props.provider || 'sanity',

// Pass along props that were extrapolated from Sanity objects
image: getAssetRef(props.image),
video: getVideoUrl(props.video),
Expand Down
38 changes: 38 additions & 0 deletions demo/content/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,41 @@ However, if multiple asssets are provided, a `<cloak-responsive>` instance is re
}]'>
</responsive-craft-visual>
```

## Sanity Visual

Here's an example of the `<sanity-visual>` adapter.

<sanity-visual
:image='{
"_type":"image",
"alt": "Sanity example image",
"asset": {
"_id": "image-c19d82f29faceae87bcf7e9cd18b08291f59f11b-3840x2160-jpg",
"url": "https://cdn.sanity.io/images/rnb0s8f2/production/c19d82f29faceae87bcf7e9cd18b08291f59f11b-3840x2160.jpg",
"metadata": {
"dimensions": {
"aspectRatio": 1.7777777778,
}
}
}
}'>
</sanity-visual>

```vue
<sanity-visual
:image='{
"_type":"image",
"alt": "Sanity example image",
"asset": {
"_id": "image-c19d82f29faceae87bcf7e9cd18b08291f59f11b-3840x2160-jpg",
"url": "https://cdn.sanity.io/images/rnb0s8f2/production/c19d82f29faceae87bcf7e9cd18b08291f59f11b-3840x2160.jpg",
"metadata": {
"dimensions": {
"aspectRatio": 1.7777777778,
}
}
}
}'>
</sanity-visual>
```
6 changes: 6 additions & 0 deletions demo/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export default {
imgix: {
baseURL: 'https://cloak-visual.imgix.net',
},

// Creds from nuxt-sanity-demo
sanity: {
projectId: 'rnb0s8f2',
dataset: 'production',
}
},

// @nuxt/content can't be loaded from module
Expand Down

0 comments on commit f51b999

Please sign in to comment.