-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update package-lock.json and .gitignore files and fix builds (#158)
* chore(example-ssr): update .gitignore * chore(example): update .gitignore * chore: update package-lock.json These changes were caused only by running `npm install` using `[email protected]"`. * fix(example-ssr): make sure broken images are handled At least one image lacks all information except `{"_type":"image","_key":"caf3ba0151b7"}` causing that blog post to break halfway through with an internal server error. * fix(example): make sure broken images are handled At least one image lacks all information except `{"_type":"image","_key":"caf3ba0151b7"}` causing the site to fail to build.
- Loading branch information
1 parent
3fd693e
commit 8562a06
Showing
5 changed files
with
28 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ pnpm-debug.log* | |
|
||
# macOS-specific files | ||
.DS_Store | ||
.vercel | ||
.env*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
--- | ||
import imageUrlBuilder from "@sanity/image-url"; | ||
import type { ImageUrlBuilder } from "@sanity/image-url/lib/types/builder"; | ||
import {sanityClient} from "sanity:client" | ||
const builder = imageUrlBuilder(sanityClient) | ||
const {node} = Astro.props | ||
const { width = 960 } = Astro.props | ||
let image: ImageUrlBuilder | undefined; | ||
// See https://www.sanity.io/docs/presenting-images for general documentation on | ||
// presenting images, and https://www.sanity.io/docs/image-url for specifics on | ||
// this builder API | ||
const image = node && builder | ||
.image(node) | ||
.width(width) | ||
.fit('max') | ||
.auto('format') | ||
try { | ||
image = node && node.asset && builder | ||
.image(node) | ||
.width(width) | ||
.fit('max') | ||
.auto('format') | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
--- | ||
|
||
{image && <img src={image.url()} alt={node.alt || ""} title={node.alt} />} | ||
{image && <img src={image.url()} alt={node.alt || ""} title={node.alt} />} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ pnpm-debug.log* | |
.DS_Store | ||
|
||
.vercel | ||
.env*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
--- | ||
import imageUrlBuilder from "@sanity/image-url"; | ||
import type { ImageUrlBuilder } from "@sanity/image-url/lib/types/builder"; | ||
import { sanityClient } from "sanity:client"; | ||
const builder = imageUrlBuilder(sanityClient) | ||
const {node} = Astro.props | ||
const { width = 960 } = Astro.props | ||
let image: ImageUrlBuilder | undefined; | ||
// See https://www.sanity.io/docs/presenting-images for general documentation on | ||
// presenting images, and https://www.sanity.io/docs/image-url for specifics on | ||
// this builder API | ||
const image = node && builder | ||
.image(node) | ||
.width(width) | ||
.fit('max') | ||
.auto('format') | ||
try { | ||
image = node && node.asset && builder | ||
.image(node) | ||
.width(width) | ||
.fit('max') | ||
.auto('format') | ||
} catch(error) { | ||
console.error(error) | ||
} | ||
--- | ||
|
||
{image && <img src={image.url()} alt={node.alt || ""} title={node.alt} />} | ||
{image && <img src={image.url()} alt={node.alt || ""} title={node.alt} />} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.