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

Improview #40

Merged
merged 10 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
variables name change
  • Loading branch information
phillysnow committed Oct 1, 2021
commit 30ab6330bd26ee7192e4419ad4f6152520117438
4 changes: 2 additions & 2 deletions pages/blog/[uid].js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ const Post = ({ post, previewRef }) => {

export async function getStaticProps({ params, previewData }) {
const previewRef = previewData ? previewData.ref : null
const options = previewRef ? { ref: previewRef } : null
const refOption = previewRef ? { ref: previewRef } : null

const post = await Client().getByUID("post", params.uid, options) || {}
const post = await Client().getByUID("post", params.uid, refOption) || {}
return {
props: {
previewRef,
Expand Down
11 changes: 5 additions & 6 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ const Home = ({ doc, posts, previewRef }) => {
export async function getStaticProps({ previewData }) {

const previewRef = previewData ? previewData.ref : null
const options = previewRef ? { ref: previewRef } : null
const refOption = previewRef ? { ref: previewRef } : null

const doc = await Client().getSingle("blog_home", options) || {}
const blogHome = await Client().getSingle("blog_home", refOption) || {}

const queryOptions = { orderings: "[my.post.date desc]", ...(options)}

const posts = await Client().query(Prismic.Predicates.at("document.type", "post"), queryOptions)
const postsQueryOptions = { orderings: "[my.post.date desc]", ...(refOption)}
const posts = await Client().query(Prismic.Predicates.at("document.type", "post"), postsQueryOptions)

return {
props: {
doc,
blogHome,
posts: posts ? posts.results : [],
previewRef,
}
Expand Down