Skip to content

Commit

Permalink
Merge pull request #30 from sanity-io/next-13
Browse files Browse the repository at this point in the history
update visual editing
  • Loading branch information
SimeonGriggs authored Jul 12, 2023
2 parents 643b5ad + ba42f83 commit f1d3028
Show file tree
Hide file tree
Showing 11 changed files with 1,120 additions and 1,135 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ yarn-error.log*
# backups
*.tar.gz

.yalc
.yalc
# Local Netlify folder
.netlify
2 changes: 1 addition & 1 deletion web/app/[language]/[course]/[lesson]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {lessonQuery} from '@/sanity/queries'
export async function generateStaticParams() {
const lessons = await getLessonsWithSlugs()

const params = lessons
const params: {language: string; course: string; lesson: string}[] = lessons
.map((lesson) => ({
...lesson,
// Couldn't filter down the object of slugs in the GROQ query,
Expand Down
2 changes: 1 addition & 1 deletion web/app/[language]/[course]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const metadata: Metadata = {
export async function generateStaticParams() {
const courses = await getCoursesWithSlugs()

const params = courses
const params: {language: string; course: string}[] = courses
.map((course) =>
i18n.languages
.map((language) =>
Expand Down
6 changes: 6 additions & 0 deletions web/app/[language]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {lazy} from 'react'

import ExitPreview from '@/components/ExitPreview'
import LegalLinks from '@/components/LegalLinks'
import VisualEditing from '@/components/VisualEditing'
import {COMMON_PARAMS, getLegals} from '@/sanity/loaders'
const PreviewProvider = lazy(() => import('@/components/PreviewProvider'))

Expand All @@ -30,6 +31,10 @@ export default async function RootLayout(props) {
</>
)

const enableVisualEditing =
(process.env.NETLIFY && process.env.CONTEXT !== 'production') ||
process.env.NODE_ENV === 'development'

return (
<html lang={props.params.language}>
<head>
Expand All @@ -44,6 +49,7 @@ export default async function RootLayout(props) {
) : (
children
)}
{enableVisualEditing ? <VisualEditing /> : null}
</body>
</html>
)
Expand Down
10 changes: 10 additions & 0 deletions web/components/VisualEditing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client'

import {enableVisualEditing} from '@sanity/overlays'
import {useEffect} from 'react'

export default function VisualEditing() {
useEffect(enableVisualEditing, [])

return null
}
Loading

2 comments on commit f1d3028

@vercel
Copy link

@vercel vercel bot commented on f1d3028 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

demo-course-platform-studio – ./studio

demo-course-platform-studio.sanity.build
demo-course-platform-studio-git-main.sanity.build

@vercel
Copy link

@vercel vercel bot commented on f1d3028 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

demo-course-platform – ./web

demo-course-platform.sanity.build
demo-course-platform-git-main.sanity.build

Please sign in to comment.