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

[Snyk] Upgrade next-sanity from 0.5.0 to 0.8.2 #620

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

snyk-bot
Copy link

Snyk has created this PR to upgrade next-sanity from 0.5.0 to 0.8.2.

merge advice
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.


  • The recommended version is 23 versions ahead of your current version.
  • The recommended version was released 21 days ago, on 2022-08-20.
Release notes
Package name: next-sanity
  • 0.8.2 - 2022-08-20

    0.8.2 (2022-08-20)

    Bug Fixes

    • deps: update dependency @ sanity/groq-store to ^0.4.1 (#71) (467e110)

    This release is also available on:

  • 0.8.1 - 2022-08-17

    0.8.1 (2022-08-17)

    Bug Fixes

    • use @ sanity/semantic-release-preset (8dec077)

    This release is also available on:

  • 0.8.0 - 2022-08-16

    0.8.0 (2022-08-16)

    Features

    • studio: add <noscript> to NextStudio (b251176)
  • 0.8.0-new-preview-mode.3 - 2022-08-12

    0.8.0-new-preview-mode.3 (2022-08-12)

    Bug Fixes

    • don't use token when in cookie mode (50b45bb)
  • 0.8.0-new-preview-mode.2 - 2022-08-12

    0.8.0-new-preview-mode.2 (2022-08-12)

    Bug Fixes

    • lazy import broken in parcel (74b839b)
  • 0.8.0-new-preview-mode.1 - 2022-08-12

    0.8.0-new-preview-mode.1 (2022-08-12)

    Bug Fixes

    Features

  • 0.7.1-new-preview-mode.2 - 2022-08-12

    0.7.1-new-preview-mode.2 (2022-08-12)

    Bug Fixes

    • lazy load code splitting (4d98286)
  • 0.7.1-new-preview-mode.1 - 2022-08-12

    0.7.1-new-preview-mode.1 (2022-08-12)

    Bug Fixes

  • 0.7.0 - 2022-08-12

    0.7.0 (2022-08-12)

    next-sanity/studio (dev-preview)

    See it live

    The latest version of Sanity Studio allows you to embed a near-infinitely configurable content editing interface into any React application. This opens up many possibilities:

    • Any service that hosts Next.js apps can now host your Studio.
    • Building previews for your content is easier as your Studio lives in the same environment.
    • Use Data Fetching to configure your Studio.
    • Easy setup of Preview Mode.

    Usage

    The basic setup is two files:

    1. pages/[[...index]].tsx
    // Import your sanity.config.ts file
    import config from '../sanity.config'
    import {NextStudio} from 'next-sanity/studio'

    export default function StudioPage() {
    // Loads the Studio, with all the needed neta tags and global CSS reqiired for it to render correctly
    return <NextStudio config={config} />
    }

    The <NextStudio /> wraps <Studio /> component and supports forwarding all its props:

    import {Studio} from 'sanity'
    1. pages/_document.tsx
    import {ServerStyleSheetDocument} from 'next-sanity/studio'

    // Set up SSR for styled-components, ensuring there's no missing CSS when deploying a Studio in Next.js into production
    export default class Document extends ServerStyleSheetDocument {}

    Opt-in to using StudioProvider and StudioLayout

    If you want to go lower level and have more control over the studio you can pass StudioProvider and StudioLayout from sanity as children:

    import {NextStudio} from 'next-sanity/studio'
    import {StudioProvider, StudioLayout} from 'sanity'

    import config from '../sanity.config'

    function StudioPage() {
    return (
    <NextStudio config={config}>
    <StudioProvider config={config}>
    {/* Put components here and you'll have access to the same React hooks as Studio gives you when writing plugins */}
    <StudioLayout />
    </StudioProvider>
    </NextStudio>
    )
    }

    Customize <ServerStyleSheetDocument />

    You can still customize _document.tsx, the same way you would the default <Document /> component from next/document:

    import {ServerStyleSheetDocument} from 'next-sanity/studio'

    export default class Document extends ServerStyleSheetDocument {
    static async getInitialProps(ctx: DocumentContext) {
    // You can still override renderPage:
    const originalRenderPage = ctx.renderPage
    ctx.renderPage = () =>
    originalRenderPage({
    enhanceApp: (App) => (props) => <App {...props} />,
    })

    <span class="pl-k">const</span> <span class="pl-s1">initialProps</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-smi">ServerStyleSheetDocument</span><span class="pl-kos">.</span><span class="pl-en">getInitialProps</span><span class="pl-kos">(</span><span class="pl-s1">ctx</span><span class="pl-kos">)</span>
    
    <span class="pl-k">const</span> <span class="pl-s1">extraStyles</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-en">getStyles</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-k">return</span> <span class="pl-kos">{</span>
      ...<span class="pl-s1">initialProps</span><span class="pl-kos">,</span>
      <span class="pl-c">// Add to the default styles if you want</span>
      <span class="pl-c1">styles</span>: <span class="pl-kos">[</span><span class="pl-s1">initialProps</span><span class="pl-kos">.</span><span class="pl-c1">styles</span><span class="pl-kos">,</span> <span class="pl-s1">extraStyles</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span>
    

    }
    render() {
    // do the same stuff as in next/document
    }
    }

    Full-control mode

    If you only need parts of what <NextStudio /> does for you, but not all of it.
    No problem. You can import any which one of the components that <NextStudio /> is importing and assemble them in any way you want.

    import {Studio, type Config} from 'sanity'
    import {NextStudioGlobalStyle, NextStudioHead} from 'next-sanity/studio'
    // This implementation will only load the bare minimum of what's required for the Studio to render correctly. No favicons, fancy <meta name="theme-color"> tags or the like
    export default function CustomNextStudio({config}: {config: Config}) {
      return (
        <>
          <Studio config={config} />
          <NextStudioHead>{/* Custom extra stuff in <head> */}</NextStudioHead>
          <NextStudioGlobalStyle />
        </>
      )
    }

    And while <NextStudio /> have all features enabled by default allowing you to opt-out by giving it props, the inner components <NextStudioHead /> and <NextStudioGlobalStyle /> are opt-in.
    This means that these two StudioPage components are functionally identical:

    import {
    NextStudio,
    NextStudioGlobalStyle,
    NextStudioHead,
    useThem,
    useBackgroundColorsFromTheme,
    } from 'next-sanity/studio'
    import {Studio} from 'sanity'
    import config from '../sanity.config'

    // Turning all the features off, leaving only bare minimum required meta tags and styling
    function StudioPage() {
    return (
    <NextStudio
    config={config}
    // an empty string turns off the CSS that sets a background on <html>
    unstable__bg=""
    unstable__noTailwindSvgFix
    unstable__noFavicons
    // an empty string turns off the <title> tag
    unstable__document_title=""
    />
    )
    }

    // Since no features are enabled it works the same way
    function Studiopage() {
    const theme = useTheme(config)
    const {themeColorLight, themeColorDark} = useBackgroundColorsFromTheme(theme)

    return (
    <>
    <Studio config={config} />
    <NextStudioHead themeColorLight={themeColorLight} themeColorDark={themeColorDark} />
    <NextStudioGlobalStyle />
    </>
    )
    }

    Features

    • add Studio v3 embed support (4edd5d0)
  • 0.6.12 - 2022-08-12

    0.6.12 (2022-08-12)

    Bug Fixes

  • 0.6.11 - 2022-08-12
  • 0.6.10 - 2022-08-12
  • 0.6.9 - 2022-08-11
  • 0.6.8 - 2022-08-11
  • 0.6.7 - 2022-08-11
  • 0.6.5 - 2022-08-11
  • 0.6.4 - 2022-08-11
  • 0.6.3 - 2022-08-11
  • 0.6.2 - 2022-08-09
  • 0.6.0 - 2022-07-04
  • 0.5.2 - 2022-04-05
  • 0.5.2-beta.0 - 2022-04-04
  • 0.5.1 - 2022-03-04
  • 0.5.0 - 2022-02-16
from next-sanity GitHub release notes
Commit messages
Package name: next-sanity

Compare


Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.

For more information:

🧐 View latest project report

🛠 Adjust upgrade PR settings

🔕 Ignore this dependency or unsubscribe from future upgrade PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant