-
Notifications
You must be signed in to change notification settings - Fork 2
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
improve: remove getting started #69
Merged
james-a-morris
merged 1 commit into
staging-blog
from
james/acx-2697-remove-getting-started
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,27 @@ | ||
import { Text } from "@/app/_components/text"; | ||
import ArticleSnippetCard from "./article-snippet-card"; | ||
import ArticleFullCard from "./article-full-card"; | ||
import { | ||
BlogPostWithRelevantEntries, | ||
retrieveContentfulPublishedSlugs, | ||
} from "@/app/_lib/contentful"; | ||
import { retrieveContentfulPublishedSlugs } from "@/app/_lib/contentful"; | ||
import { SearchParams } from "../page"; | ||
import { useState } from "react"; | ||
|
||
export async function Posts({ | ||
getStartedSnippets, | ||
recentArticleSlugs, | ||
searchParams, | ||
}: { | ||
searchParams: SearchParams; | ||
recentArticleSlugs: string[]; | ||
getStartedSnippets: (BlogPostWithRelevantEntries | undefined)[]; | ||
}) { | ||
export async function Posts({ searchParams }: { searchParams: SearchParams }) { | ||
const search = searchParams["search"]; | ||
if (!search) { | ||
return ( | ||
<> | ||
<div className="flex w-full flex-col gap-4"> | ||
<Text variant="body" className="text-grey-400"> | ||
Get started with Across | ||
</Text> | ||
<div className="w-full overflow-x-scroll scrollbar-hide"> | ||
<div className="grid w-[1024px] grid-cols-3 gap-5 md:w-full"> | ||
{getStartedSnippets.slice(0, 3).map((snippet) => ( | ||
<div className="w-full" key={snippet?.fields.slug}> | ||
<ArticleSnippetCard article={snippet!} /> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
<div className="flex w-full flex-col gap-4"> | ||
<Text variant="body" className="text-grey-400"> | ||
Most recent articles | ||
</Text> | ||
{recentArticleSlugs.map((slug) => ( | ||
<ArticleFullCard key={slug} slug={slug} /> | ||
))} | ||
</div> | ||
</> | ||
); | ||
} else { | ||
const searchedSlugs = await retrieveContentfulPublishedSlugs({ | ||
query: search, | ||
}); | ||
return searchedSlugs.length === 0 ? ( | ||
<h2 className="text-2xl my-auto flex-1 text-grey-400">No results.</h2> | ||
) : ( | ||
<div className="flex w-full flex-col gap-4"> | ||
<Text variant="body" className="text-grey-400"> | ||
Search results | ||
</Text> | ||
{searchedSlugs.map((slug) => ( | ||
<ArticleFullCard key={slug} slug={slug} /> | ||
))} | ||
</div> | ||
); | ||
} | ||
const isSearch = Boolean(!!search); | ||
const pageLength = 6; | ||
const searchedSlugs = await retrieveContentfulPublishedSlugs({ | ||
query: search ? decodeURI(search) : undefined, | ||
sortByRecent: true, | ||
limit: pageLength, | ||
}); | ||
|
||
return ( | ||
<div className="flex w-full flex-col gap-4"> | ||
<Text variant="body" className="text-grey-400"> | ||
{isSearch ? "Search results" : "Most recent articles"} | ||
</Text> | ||
{searchedSlugs.map((slug) => ( | ||
<ArticleFullCard key={slug} slug={slug} /> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: pass your
key
generated usingcreateCacheKey
as a key to<Suspense>
. this will force it to show the fallback text while it fetches new data. Unless you don't want that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done on line 32