-
Notifications
You must be signed in to change notification settings - Fork 619
[MNY-216] Update SEO metadata on chain pages, Add FAQ section #8135
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
Merged
+199
−50
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/apis/chain-seo.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import "server-only"; | ||
| import { unstable_cache } from "next/cache"; | ||
|
|
||
| export type ChainSeo = { | ||
| title: string; | ||
| description: string; | ||
| og: { | ||
| title: string; | ||
| description: string; | ||
| site_name: string; | ||
| url: string; | ||
| }; | ||
| faqs: Array<{ | ||
| title: string; | ||
| description: string; | ||
| }>; | ||
| chain: { | ||
| chainId: number; | ||
| name: string; | ||
| slug: string; | ||
| nativeCurrency: { | ||
| name: string; | ||
| symbol: string; | ||
| decimals: number; | ||
| }; | ||
| testnet: boolean; | ||
| is_deprecated: boolean; | ||
| }; | ||
| }; | ||
|
|
||
| export const fetchChainSeo = unstable_cache( | ||
| async (chainId: number) => { | ||
| const url = new URL( | ||
| `https://seo-pages-generator-5814.zeet-nftlabs.zeet.app/chain/${chainId}`, | ||
| ); | ||
| const res = await fetch(url, { | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }); | ||
|
|
||
| if (!res.ok) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return res.json() as Promise<ChainSeo>; | ||
| }, | ||
| ["chain-seo"], | ||
| { revalidate: 60 * 60 * 24 }, // 24 hours | ||
| ); | ||
This file contains hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
...rc/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/server/faq-section.tsx
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| "use client"; | ||
| import { ChevronDownIcon } from "lucide-react"; | ||
| import { useId, useState } from "react"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { DynamicHeight } from "@/components/ui/DynamicHeight"; | ||
| import { cn } from "@/lib/utils"; | ||
| import type { ChainSeo } from "../../apis/chain-seo"; | ||
|
|
||
| export function FaqSection(props: { faqs: ChainSeo["faqs"] }) { | ||
| return ( | ||
| <div className="py-10"> | ||
| <section className=""> | ||
| <h2 className="text-2xl md:text-3xl font-semibold mb-4 tracking-tight"> | ||
| Frequently asked questions | ||
| </h2> | ||
| <div className="flex flex-col"> | ||
| {props.faqs.map((faq, faqIndex) => ( | ||
| <FaqItem | ||
| key={faq.title} | ||
| title={faq.title} | ||
| description={faq.description} | ||
| className={cn(faqIndex === props.faqs.length - 1 && "border-b-0")} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </section> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function FaqItem(props: { | ||
| title: string; | ||
| description: string; | ||
| className?: string; | ||
| }) { | ||
| const [isOpen, setIsOpenn] = useState(false); | ||
| const contentId = useId(); | ||
| return ( | ||
| <DynamicHeight> | ||
| <div className={cn("border-b border-dashed", props.className)}> | ||
| <h3> | ||
| <Button | ||
| variant="ghost" | ||
| onClick={() => setIsOpenn(!isOpen)} | ||
| aria-controls={contentId} | ||
| aria-expanded={isOpen} | ||
| className={cn( | ||
| "w-full justify-between h-auto py-5 text-base text-muted-foreground hover:bg-transparent pl-0 text-wrap text-left gap-6", | ||
| isOpen && "text-foreground", | ||
| )} | ||
| > | ||
| {props.title} | ||
| <ChevronDownIcon | ||
| className={cn( | ||
| "size-4 shrink-0 transition-transform duration-200", | ||
| isOpen && "rotate-180", | ||
| )} | ||
| /> | ||
| </Button> | ||
| </h3> | ||
|
|
||
| <p | ||
| className={cn( | ||
| "text-muted-foreground text-base leading-7 pb-6 max-w-4xl", | ||
| !isOpen && "hidden", | ||
| )} | ||
| id={contentId} | ||
| > | ||
| {props.description} | ||
| </p> | ||
| </div> | ||
| </DynamicHeight> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.