generated from sanity-io/nextjs-blog-cms-sanity-v3
-
Notifications
You must be signed in to change notification settings - Fork 105
feat: migrate to sanity-image, enhance page builder, update next-sanity #156
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
Open
kenjonespizza
wants to merge
30
commits into
main
Choose a base branch
from
feat-updates-images-and-page-builder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
6479d1c
Updated package files
codebravotech ce3b4b8
Updated lockfile
codebravotech f969f97
Shared utils
codebravotech 406d219
Updates to the CTA
codebravotech f8919a6
Add image support for blocks
codebravotech 3388da1
Fix the viewport width/height based cover image (changed it so that d…
codebravotech 5c740c2
Fix issue in the media hook
codebravotech 95f14b2
Remove mux video package (unneeded accidental addition from my other …
codebravotech b5abfe6
Update collapsability of button
codebravotech 067933d
Update package versions and move to JSX based page renderer to fix us…
codebravotech 201d3a9
Merge pull request #1 from codebravotech/jp/feat/updated-page-building
codebravotech e945adf
Merge remote-tracking branch 'upstream/main' into jp/feat/updated-pag…
codebravotech bf2700b
Merge remote-tracking branch 'origin/jp/feat/updated-page-building'
codebravotech b9ab740
Updated CTA with color theming options
codebravotech eb2eddf
Clickable overlay for the page builder when its empty
codebravotech f85615d
collapsable layout section
codebravotech f7c76b9
iterate on the changes to the page builder blocks and image component.
kenjonespizza 98aee66
remove un-needed h3-h6 from <PortableText>
kenjonespizza e0474c8
swap Avatar image component. update studio icons. various small rev…
kenjonespizza 46e3bdf
make imports consistent
kenjonespizza 9231d5f
Merge branch 'main' into feat/updates-images-and-page-builder
kenjonespizza aeaa0ec
extract types
kenjonespizza b89b03f
attempt Vercel build
kenjonespizza e63c9ad
update broken 'open in studio link' and simplify stega config in the …
kenjonespizza a284a6f
update sample data for new stucture
kenjonespizza 13ea172
modify createDataAttribute. Remove un-needed Suspense
kenjonespizza 92ff44b
fix merge conflict. Merge in main
kenjonespizza a071d19
upgrade React, Next, and Sanity dependencies
kenjonespizza 2a03d5c
upgrade packages and merge in upgrades made in main
kenjonespizza 81ed02d
fix homepage PTE not showing Overlay
kenjonespizza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,37 +1,91 @@ | ||
| import {Suspense} from 'react' | ||
| import { Suspense } from "react"; | ||
| import { PortableTextBlock } from "next-sanity"; | ||
|
|
||
| import ResolvedLink from '@/app/components/ResolvedLink' | ||
| import {CallToAction} from '@/sanity.types' | ||
| import ResolvedLink from "@/app/components/ResolvedLink"; | ||
| import PortableText from "@/app/components/PortableText"; | ||
| import Image from "@/app/components/SanityImage"; | ||
| import { stegaClean } from "@sanity/client/stega"; | ||
| import { ExtractPageBuilderType } from "@/sanity/lib/types"; | ||
|
|
||
| type CtaProps = { | ||
| block: CallToAction | ||
| index: number | ||
| } | ||
| block: ExtractPageBuilderType<"callToAction">; | ||
| index: number; | ||
| // Needed if you want to createDataAttributes to do non-text overlays in Presentation (Visual Editing) | ||
| pageType: string; | ||
| pageId: string; | ||
| }; | ||
|
|
||
| export default function CTA({ block }: CtaProps) { | ||
| const { | ||
| heading, | ||
| eyebrow, | ||
| body = [], | ||
| button, | ||
| image, | ||
| theme, | ||
| contentAlignment, | ||
| } = block; | ||
|
|
||
| const isDark = theme === "dark"; | ||
| const isImageFirst = stegaClean(contentAlignment) === "imageFirst"; | ||
|
|
||
| export default function CTA({block}: CtaProps) { | ||
| return ( | ||
| <div className="container my-12"> | ||
| <div className="bg-gray-50 border border-gray-100 rounded-2xl max-w-3xl"> | ||
| <div className="px-12 py-12 flex flex-col gap-6"> | ||
| <div className="max-w-xl flex flex-col gap-3"> | ||
| <h2 className="text-3xl font-bold tracking-tight text-black sm:text-4xl"> | ||
| {block.heading} | ||
| </h2> | ||
| <p className="text-lg leading-8 text-gray-600">{block.text}</p> | ||
| <section | ||
| className={ | ||
| isDark ? "relative dark dark:bg-black" : "relative dark:bg-black" | ||
| } | ||
| > | ||
| <div className="absolute inset-0 bg-size-[5px] bg-[url(/images/tile-1-black.png)] dark:bg-[url(/images/tile-1-white.png)] opacity-25" /> | ||
| <div className="container relative"> | ||
| <div className="grid lg:grid-cols-2 gap-12 py-12"> | ||
| <div | ||
| className={`${isImageFirst && image ? "row-start-2 lg:row-start-1 lg:col-start-2" : ""} flex flex-col gap-2 `} | ||
| > | ||
| {eyebrow && ( | ||
| <span className="text-sm uppercase dark:text-white font-mono tracking-tight opacity-70"> | ||
| {eyebrow} | ||
| </span> | ||
| )} | ||
| {heading && ( | ||
| <h2 className="text-2xl md:text-3xl lg:text-4xl dark:text-white"> | ||
| {heading} | ||
| </h2> | ||
| )} | ||
| {body && ( | ||
| <div className="lg:text-left"> | ||
| <PortableText | ||
| value={body as PortableTextBlock[]} | ||
| className="dark:prose-invert" | ||
| /> | ||
| </div> | ||
| )} | ||
|
|
||
| <Suspense fallback={null}> | ||
| {button?.buttonText && button?.link && ( | ||
| <div className="flex mt-4"> | ||
| <ResolvedLink | ||
| link={button?.link} | ||
| className="rounded-full flex gap-2 font-mono text-sm whitespace-nowrap items-center bg-black dark:bg-white hover:bg-blue focus:bg-blue py-3 px-6 text-white dark:text-black dark:hover:text-white transition-colors duration-200" | ||
| > | ||
| {button?.buttonText} | ||
| </ResolvedLink> | ||
| </div> | ||
| )} | ||
| </Suspense> | ||
| </div> | ||
|
|
||
| <Suspense fallback={null}> | ||
| <div className="flex items-center gap-x-6 lg:mt-0 lg:flex-shrink-0"> | ||
| <ResolvedLink | ||
| link={block.link} | ||
| className="rounded-full flex gap-2 mr-6 items-center bg-black hover:bg-blue focus:bg-blue py-3 px-6 text-white transition-colors duration-200" | ||
| > | ||
| {block.buttonText} | ||
| </ResolvedLink> | ||
| </div> | ||
| </Suspense> | ||
| {image?.asset?._ref && ( | ||
| <Image | ||
| id={image.asset._ref} | ||
| alt="Demo image" | ||
| width={704} | ||
| crop={image.crop} | ||
| mode="cover" | ||
| className="rounded-sm" | ||
| /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| </section> | ||
| ); | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.