mirror of
https://github.com/LaconicNetwork/laconic.com.git
synced 2026-01-17 04:14:09 +00:00
Signed-off-by: Traxus <shyidx@gmail.com>
This commit is contained in:
parent
0bba1348ad
commit
985febebd9
@ -73,7 +73,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
|
||||
postsSlugsJson = await getAllBlogPostsSlugs()
|
||||
}
|
||||
|
||||
return postsSlugsJson
|
||||
return postsSlugsJson
|
||||
}
|
||||
|
||||
const posts = await postsSlugsJsonFromSource()
|
||||
@ -102,7 +102,7 @@ export const getStaticProps: GetStaticProps = async (
|
||||
//===== \/ START NEXT_PUBLIC_DATOCMS_BYPASS \/ ====================================================
|
||||
|
||||
//const post = await (await cms().SingleBlogPost({ slug })).blogPost
|
||||
const post: any = await getSingleBlogPostBySlugFromSource(slug)
|
||||
const post: any = await getSingleBlogPostBySlugFromSource(slug)
|
||||
|
||||
/*
|
||||
const allBlogPosts = await serverGetBlogPosts({
|
||||
@ -120,7 +120,7 @@ export const getStaticProps: GetStaticProps = async (
|
||||
let relatedBlogPostsFromSource = []
|
||||
|
||||
if (process.env.NEXT_PUBLIC_DATOCMS_BYPASS_TYPE === 'local_json') {
|
||||
relatedBlogPostsFromSource = await getRelatedBlogPosts(post, 3)
|
||||
relatedBlogPostsFromSource = await getRelatedBlogPosts(post, 3)
|
||||
} else {
|
||||
const allBlogPosts = await serverGetBlogPosts({
|
||||
filterSlugs: [slug],
|
||||
@ -130,7 +130,8 @@ export const getStaticProps: GetStaticProps = async (
|
||||
relatedBlogPostsFromSource = allBlogPosts.data.filter((p) =>
|
||||
p.category.some((c) =>
|
||||
post?.category.some(
|
||||
(postCategory: any) => c.slug === postCategory.slug)
|
||||
(postCategory: any) => c.slug === postCategory.slug
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@ -115,13 +115,16 @@ const BlogIndexPage = ({
|
||||
}
|
||||
: undefined,
|
||||
getNextPageParam: (lastPage) =>
|
||||
lastPage.pagination.nextPage ?? undefined
|
||||
lastPage.pagination.nextPage ?? undefined
|
||||
}
|
||||
)
|
||||
|
||||
let queriedPostsHasResults = false
|
||||
|
||||
if (typeof queriedPosts !== 'undefined' && 'pages' in queriedPosts === true) {
|
||||
if (
|
||||
typeof queriedPosts !== 'undefined' &&
|
||||
'pages' in queriedPosts === true)
|
||||
{
|
||||
if (0 in queriedPosts.pages === true) {
|
||||
if ('pagination' in queriedPosts.pages[0]) {
|
||||
if ('total' in queriedPosts.pages[0].pagination) {
|
||||
@ -168,7 +171,7 @@ const BlogIndexPage = ({
|
||||
</nav>
|
||||
|
||||
<SearchBar
|
||||
search={!Array.isArray(s) ? s: ''}
|
||||
search={!Array.isArray(s) ? s : ''}
|
||||
onChange={handleSearch}
|
||||
key={'search'}
|
||||
/>
|
||||
@ -183,10 +186,10 @@ const BlogIndexPage = ({
|
||||
))}
|
||||
</Fragment>
|
||||
))
|
||||
): (
|
||||
) : (
|
||||
<p>No results.</p>
|
||||
)
|
||||
): (
|
||||
) : (
|
||||
<p>Loading...</p>
|
||||
)}
|
||||
</PostsGrid>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user