Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sanity demo #22

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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