Signed-off-by: Traxus <shyidx@gmail.com>

This commit is contained in:
Traxus 2023-04-24 17:51:21 -04:00
parent 92cd414663
commit 0fdc371202
3 changed files with 19 additions and 4 deletions

View File

@ -21,6 +21,21 @@ function datocmsDateToIng(date: string): number {
return dateInt
}
export function queriedPostsHasResults(queriedPosts: any) {
if ('pages' in queriedPosts === true) {
if (0 in queriedPosts.pages === true) {
if ('pagination' in queriedPosts.pages[0]) {
if ('total' in queriedPosts.pages[0].pagination) {
if (queriedPosts.pages[0].pagination.total > 0) {
return true
}
}
}
}
}
return false
}
//-----graphql query interception
export async function datocmsQueryIntercept(query: any) {
const parent = pluckFirstParentFromQuery(query)
@ -260,7 +275,7 @@ function getBlogJsonDirectoryPath() {
function pluckBlogPostData(json: any) {
//let plucked: BlogPostRecord = {}
let plucked: any = {}
if ('data' in json) {
if ('blogPost' in json.data) {
plucked = json.data.blogPost

View File

@ -1,11 +1,11 @@
import tiny from 'tiny-json-http'
//===== \/ START NEXT_PUBLIC_DATOCMS_BYPASS \/ ====================================================
import { datocmsQueryIntercept } from 'lib/datocms-bypass'
//===== /\ FINISH NEXT_PUBLIC_DATOCMS_BYPASS /\ ====================================================
import tiny from 'tiny-json-http'
interface props {
query: string
variables?: string

View File

@ -137,7 +137,7 @@ export const getStaticProps: GetStaticProps = async (
const relatedPosts = allBlogPosts.data.filter((p) =>
p.category.some((c) =>
post?.category.some(
(postCategory: any) => c.slug === postCategory.slug)
(postCategory: any) => c.slug === postCategory.slug)
)
)