Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 2a62d24

Browse files
committed
Add preview props to dynamic routes
1 parent 0701aeb commit 2a62d24

File tree

8 files changed

+56
-40
lines changed

8 files changed

+56
-40
lines changed

pages/[...slug].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ export async function getStaticPaths() {
5454
* Get post static props.
5555
*
5656
* @author WebDevStudios
57-
* @param {object} context Context for current post.
58-
* @param {object} context.params Route parameters for current post.
59-
* @return {object} Post props.
57+
* @param {object} context Context for current post.
58+
* @param {object} context.params Route parameters for current post.
59+
* @param {boolean} context.preview Whether requesting preview of post.
60+
* @param {object} context.previewData Post preview data.
61+
* @return {object} Post props.
6062
*/
61-
export async function getStaticProps({params}) {
62-
return getPostTypeStaticProps(params, postType)
63+
export async function getStaticProps({params, preview, previewData}) {
64+
return getPostTypeStaticProps(params, postType, preview, previewData)
6365
}
6466

6567
Page.propTypes = {

pages/blog/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
BlogPost.propTypes = {

pages/careers/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
Career.propTypes = {

pages/events/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
Event.propTypes = {

pages/portfolio/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
Portfolio.propTypes = {

pages/service/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
Service.propTypes = {

pages/team/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
Team.propTypes = {

pages/testimonial/[[...slug]].js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export async function getStaticPaths() {
9191
* Get post static props.
9292
*
9393
* @author WebDevStudios
94-
* @param {object} context Context for current post.
95-
* @param {object} context.params Route parameters for current post.
96-
* @return {object} Post props.
94+
* @param {object} context Context for current post.
95+
* @param {object} context.params Route parameters for current post.
96+
* @param {boolean} context.preview Whether requesting preview of post.
97+
* @param {object} context.previewData Post preview data.
98+
* @return {object} Post props.
9799
*/
98-
export async function getStaticProps({params}) {
99-
return getPostTypeStaticProps(params, postType)
100+
export async function getStaticProps({params, preview, previewData}) {
101+
return getPostTypeStaticProps(params, postType, preview, previewData)
100102
}
101103

102104
Testimonial.propTypes = {

0 commit comments

Comments
 (0)