Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
b41f9baa
Unverified
Commit
b41f9baa
authored
May 13, 2020
by
Joe Haddad
Committed by
GitHub
May 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up CMS examples (#12840)
parent
f1423518
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
15 deletions
+15
-15
[slug].js
examples/cms-contentful/pages/posts/[slug].js
+3
-3
index.js
examples/cms-datocms/pages/index.js
+1
-1
[slug].js
examples/cms-datocms/pages/posts/[slug].js
+2
-2
index.js
examples/cms-prismic/pages/index.js
+1
-1
[slug].js
examples/cms-prismic/pages/posts/[slug].js
+3
-3
[slug].js
examples/cms-sanity/pages/posts/[slug].js
+2
-2
index.js
examples/cms-takeshape/pages/index.js
+1
-1
[slug].js
examples/cms-takeshape/pages/posts/[slug].js
+2
-2
No files found.
examples/cms-contentful/pages/posts/[slug].js
View file @
b41f9baa
...
@@ -59,8 +59,8 @@ export async function getStaticProps({ params, preview = false }) {
...
@@ -59,8 +59,8 @@ export async function getStaticProps({ params, preview = false }) {
return
{
return
{
props
:
{
props
:
{
preview
,
preview
,
post
:
data
?.
post
,
post
:
data
?.
post
??
null
,
morePosts
:
data
?.
morePosts
,
morePosts
:
data
?.
morePosts
??
null
,
},
},
}
}
}
}
...
@@ -68,7 +68,7 @@ export async function getStaticProps({ params, preview = false }) {
...
@@ -68,7 +68,7 @@ export async function getStaticProps({ params, preview = false }) {
export
async
function
getStaticPaths
()
{
export
async
function
getStaticPaths
()
{
const
allPosts
=
await
getAllPostsWithSlug
()
const
allPosts
=
await
getAllPostsWithSlug
()
return
{
return
{
paths
:
allPosts
?.
map
(({
slug
})
=>
`/posts/
${
slug
}
`
)
||
[],
paths
:
allPosts
?.
map
(({
slug
})
=>
`/posts/
${
slug
}
`
)
??
[],
fallback
:
true
,
fallback
:
true
,
}
}
}
}
examples/cms-datocms/pages/index.js
View file @
b41f9baa
...
@@ -35,7 +35,7 @@ export default function Index({ allPosts }) {
...
@@ -35,7 +35,7 @@ export default function Index({ allPosts }) {
)
)
}
}
export
async
function
getStaticProps
({
preview
})
{
export
async
function
getStaticProps
({
preview
=
false
})
{
const
allPosts
=
(
await
getAllPostsForHome
(
preview
))
||
[]
const
allPosts
=
(
await
getAllPostsForHome
(
preview
))
||
[]
return
{
return
{
props
:
{
allPosts
},
props
:
{
allPosts
},
...
...
examples/cms-datocms/pages/posts/[slug].js
View file @
b41f9baa
...
@@ -50,7 +50,7 @@ export default function Post({ post, morePosts, preview }) {
...
@@ -50,7 +50,7 @@ export default function Post({ post, morePosts, preview }) {
)
)
}
}
export
async
function
getStaticProps
({
params
,
preview
=
null
})
{
export
async
function
getStaticProps
({
params
,
preview
=
false
})
{
const
data
=
await
getPostAndMorePosts
(
params
.
slug
,
preview
)
const
data
=
await
getPostAndMorePosts
(
params
.
slug
,
preview
)
const
content
=
await
markdownToHtml
(
data
?.
post
?.
content
||
''
)
const
content
=
await
markdownToHtml
(
data
?.
post
?.
content
||
''
)
...
@@ -61,7 +61,7 @@ export async function getStaticProps({ params, preview = null }) {
...
@@ -61,7 +61,7 @@ export async function getStaticProps({ params, preview = null }) {
...
data
?.
post
,
...
data
?.
post
,
content
,
content
,
},
},
morePosts
:
data
?.
morePosts
,
morePosts
:
data
?.
morePosts
??
[]
,
},
},
}
}
}
}
...
...
examples/cms-prismic/pages/index.js
View file @
b41f9baa
...
@@ -35,7 +35,7 @@ export default function Index({ preview, allPosts }) {
...
@@ -35,7 +35,7 @@ export default function Index({ preview, allPosts }) {
)
)
}
}
export
async
function
getStaticProps
({
preview
,
previewData
})
{
export
async
function
getStaticProps
({
preview
=
false
,
previewData
})
{
const
allPosts
=
await
getAllPostsForHome
(
previewData
)
const
allPosts
=
await
getAllPostsForHome
(
previewData
)
return
{
return
{
props
:
{
preview
,
allPosts
},
props
:
{
preview
,
allPosts
},
...
...
examples/cms-prismic/pages/posts/[slug].js
View file @
b41f9baa
...
@@ -52,14 +52,14 @@ export default function Post({ post, morePosts, preview }) {
...
@@ -52,14 +52,14 @@ export default function Post({ post, morePosts, preview }) {
)
)
}
}
export
async
function
getStaticProps
({
params
,
preview
,
previewData
})
{
export
async
function
getStaticProps
({
params
,
preview
=
false
,
previewData
})
{
const
data
=
await
getPostAndMorePosts
(
params
.
slug
,
previewData
)
const
data
=
await
getPostAndMorePosts
(
params
.
slug
,
previewData
)
return
{
return
{
props
:
{
props
:
{
preview
,
preview
,
post
:
data
?.
post
,
post
:
data
?.
post
??
null
,
morePosts
:
data
?.
morePosts
,
morePosts
:
data
?.
morePosts
??
[]
,
},
},
}
}
}
}
...
...
examples/cms-sanity/pages/posts/[slug].js
View file @
b41f9baa
...
@@ -54,8 +54,8 @@ export async function getStaticProps({ params, preview = false }) {
...
@@ -54,8 +54,8 @@ export async function getStaticProps({ params, preview = false }) {
return
{
return
{
props
:
{
props
:
{
preview
,
preview
,
post
:
data
.
post
||
null
,
post
:
data
?
.
post
||
null
,
morePosts
:
data
.
morePosts
||
null
,
morePosts
:
data
?
.
morePosts
||
null
,
},
},
}
}
}
}
...
...
examples/cms-takeshape/pages/index.js
View file @
b41f9baa
...
@@ -35,7 +35,7 @@ export default function Index({ allPosts, preview }) {
...
@@ -35,7 +35,7 @@ export default function Index({ allPosts, preview }) {
)
)
}
}
export
async
function
getStaticProps
({
preview
=
null
})
{
export
async
function
getStaticProps
({
preview
=
false
})
{
const
allPosts
=
await
getAllPostsForHome
(
preview
)
const
allPosts
=
await
getAllPostsForHome
(
preview
)
return
{
return
{
props
:
{
allPosts
,
preview
},
props
:
{
allPosts
,
preview
},
...
...
examples/cms-takeshape/pages/posts/[slug].js
View file @
b41f9baa
...
@@ -59,7 +59,7 @@ export default function Post({ post, morePosts, preview }) {
...
@@ -59,7 +59,7 @@ export default function Post({ post, morePosts, preview }) {
)
)
}
}
export
async
function
getStaticProps
({
params
,
preview
=
null
})
{
export
async
function
getStaticProps
({
params
,
preview
=
false
})
{
const
data
=
await
getPostAndMorePosts
(
params
.
slug
,
preview
)
const
data
=
await
getPostAndMorePosts
(
params
.
slug
,
preview
)
const
content
=
await
markdownToHtml
(
const
content
=
await
markdownToHtml
(
(
data
?.
post
?.
items
||
[])[
0
]?.
content
||
''
(
data
?.
post
?.
items
||
[])[
0
]?.
content
||
''
...
@@ -72,7 +72,7 @@ export async function getStaticProps({ params, preview = null }) {
...
@@ -72,7 +72,7 @@ export async function getStaticProps({ params, preview = null }) {
...(
data
?.
post
?.
items
||
[])[
0
],
...(
data
?.
post
?.
items
||
[])[
0
],
content
,
content
,
},
},
morePosts
:
data
?.
morePosts
.
items
,
morePosts
:
data
?.
morePosts
.
items
??
[]
,
},
},
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment