Skip to content

Commit

Permalink
feat: sitemap (#290)
Browse files Browse the repository at this point in the history
* feat: add sitemap

* fix: error handling

* fix: move common types

* fix: update base url in sitemap

* Update apps/webapp/app/(routes)/[lang]/blog/[category]/sitemap.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Update apps/webapp/app/(routes)/[lang]/wallet/sitemap.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* Update apps/webapp/app/(routes)/[lang]/whitepaper/sitemap.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* fix: build error

* fix: remove unnecessary async declarative

* vendor: add @types/uuid

* fix: remove console log for debug

* fix: add 'async' to all sitemaps

* fix: make ProjectPageParams extends CommonPageParams

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
TopETH and sourcery-ai[bot] authored Jul 29, 2024
1 parent 0859420 commit 31a5ce9
Show file tree
Hide file tree
Showing 31 changed files with 350 additions and 27 deletions.
8 changes: 2 additions & 6 deletions apps/webapp/app/(routes)/[lang]/[project]/auction/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDictionary } from '@/dictionaries'
import { Lang, locales } from '@/dictionaries/locales'
import { locales } from '@/dictionaries/locales'
import { AuctionBids } from '@/components/routes/project/auction/auction-bids'
import { AuctionDataCard } from '@/components/routes/project/auction/auction-data-card'
import { ProjectHeader } from '@/components/routes/project/project-header'
Expand All @@ -18,6 +18,7 @@ import {
getProjects
} from '@/lib/projects'
import { redirect } from 'next/navigation'
import { ProjectPageProps, ProjectPageParams } from '@/types/routing.type'

export default async function AuctionPage({ params }: ProjectPageProps) {
const dict = await getDictionary(params.lang)
Expand Down Expand Up @@ -73,8 +74,3 @@ export async function generateStaticParams(): Promise<ProjectPageParams[]> {

return params
}

type ProjectPageParams = { project: string; lang: Lang }
type ProjectPageProps = {
params: ProjectPageParams
}
16 changes: 16 additions & 0 deletions apps/webapp/app/(routes)/[lang]/[project]/auction/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MetadataRoute } from 'next'
import { getDictionary } from '@/dictionaries'
import { getProjects } from '@/lib/projects'
import { ProjectPageProps } from '@/types/routing.type'

export default async function sitemap({
params
}: ProjectPageProps): Promise<MetadataRoute.Sitemap> {
const dict = await getDictionary(params.lang)
const projects = await getProjects(dict)

return projects.map(project => ({
url: `https://${process.env.VERCEL_URL}/${params.lang}/${project.slug}/auction`,
lastModified: new Date()
}))
}
9 changes: 2 additions & 7 deletions apps/webapp/app/(routes)/[lang]/[project]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getDictionary } from '@/dictionaries'
import { Lang } from '@/dictionaries/locales'
import { ProjectPageProps, ProjectPagePropsWithChildren } from '@/types/routing.type'
import { getProjectBySlug } from '@/lib/projects'
import { Metadata } from 'next'

export default function ProjectPagesLayout({ children }: ProjectPageProps) {
export default function ProjectPagesLayout({ children }: ProjectPagePropsWithChildren) {
return children
}

Expand All @@ -20,8 +20,3 @@ export async function generateMetadata({
}
}
}
interface ProjectPageProps {
children: React.ReactNode
params: ProjectPageParams
}
type ProjectPageParams = { project: string; lang: Lang }
8 changes: 2 additions & 6 deletions apps/webapp/app/(routes)/[lang]/[project]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { Countdown } from '@/components/shared/countdown'
import Link from 'next/link'
import dynamic from 'next/dynamic'
import { Button } from '@/components/ui/button'
import { Lang, locales } from '@/dictionaries/locales'
import { locales } from '@/dictionaries/locales'
import { getDictionary } from '@/dictionaries'
import { appConfig } from '@/lib/config'
import Image from 'next/image'
import { ProjectPageProps, ProjectPageParams } from '@/types/routing.type'

export default async function ProjectPage({ params }: ProjectPageProps) {
const dict = await getDictionary(params.lang)
Expand Down Expand Up @@ -130,11 +131,6 @@ export async function generateStaticParams(): Promise<ProjectPageParams[]> {
return params
}

type ProjectPageParams = { project: string; lang: Lang }
type ProjectPageProps = {
params: ProjectPageParams
}

const DynamicAddressForm = dynamic(
() =>
import('../../../../components/routes/project/register-address-form').then(
Expand Down
6 changes: 1 addition & 5 deletions apps/webapp/app/(routes)/[lang]/[project]/presale/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Card, CardContent } from '@/components/ui/card'
import { Countdown } from '@/components/shared/countdown'
import { ProjectPresaleData } from '@/components/routes/project/project-presale-data'
import { PresaleTransactionsCard } from '@/components/routes/project/presale/presale-transactions-card'
import { Lang } from '@/dictionaries/locales'
import { ProjectPageProps } from '@/types/routing.type'
import { getDictionary } from '@/dictionaries'
import { PresaleDepositCard } from '@/components/routes/project/presale/presale-deposit-card'

Expand Down Expand Up @@ -36,7 +36,3 @@ export default async function ProjectPage({ params }: ProjectPageProps) {
</div>
)
}

type ProjectPageProps = {
params: { project: string; lang: Lang }
}
16 changes: 16 additions & 0 deletions apps/webapp/app/(routes)/[lang]/[project]/presale/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MetadataRoute } from 'next'
import { getDictionary } from '@/dictionaries'
import { getProjects } from '@/lib/projects'
import { ProjectPageProps } from '@/types/routing.type'

export default async function sitemap({
params
}: ProjectPageProps): Promise<MetadataRoute.Sitemap> {
const dict = await getDictionary(params.lang)
const projects = await getProjects(dict)

return projects.map(project => ({
url: `https://${process.env.VERCEL_URL}/${params.lang}/${project.slug}/presale`,
lastModified: new Date()
}))
}
16 changes: 16 additions & 0 deletions apps/webapp/app/(routes)/[lang]/[project]/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MetadataRoute } from 'next'
import { getDictionary } from '@/dictionaries'
import { getProjects } from '@/lib/projects'
import { ProjectPageProps } from '@/types/routing.type'

export default async function sitemap({
params
}: ProjectPageProps): Promise<MetadataRoute.Sitemap> {
const dict = await getDictionary(params.lang)
const projects = await getProjects(dict)

return projects.map(project => ({
url: `https://${process.env.VERCEL_URL}/${params.lang}/${project.slug}`,
lastModified: new Date()
}))
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/about/ai-startups/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/about/ai-startups`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/about/bitcash-app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/about/bitcash-app`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/about/communities/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/about/communities`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/about/daos-dboard/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/about/daos-dboard`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/about/investors/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/about/investors`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/about/referrals/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/about/referrals`,
lastModified: new Date()
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ export async function generateStaticParams(): Promise<ArticlePageParams[]> {
}

type ArticlePageParams = { lang: Lang; category: string; slug: string }
type ArticlePageProps = { params: ArticlePageParams }
export type ArticlePageProps = { params: ArticlePageParams }
23 changes: 23 additions & 0 deletions apps/webapp/app/(routes)/[lang]/blog/[category]/[slug]/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MetadataRoute } from 'next'
import { getBlogCategoryLandingData } from '@/services/datocms'
import { ArticlePageProps } from './page'

export default async function sitemap(
props: ArticlePageProps
): Promise<MetadataRoute.Sitemap> {
const {
params: { lang, category }
} = props
const data = await getBlogCategoryLandingData(lang, category)
if (!data) return []

const { sections } = data
if (!sections) return []

const slugs = sections.map((section: any) => section.slug)

return slugs.map((slug: any) => ({
url: `https://${process.env.VERCEL_URL}/${lang}/blog/${category}/${slug}`,
lastModified: new Date()
}))
}
2 changes: 1 addition & 1 deletion apps/webapp/app/(routes)/[lang]/blog/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ export async function generateMetadata(props: any): Promise<Metadata> {
}

type CategoryPageParams = { lang: Lang; category: string }
type CategoryPageProps = { params: CategoryPageParams }
export type CategoryPageProps = { params: CategoryPageParams }
23 changes: 23 additions & 0 deletions apps/webapp/app/(routes)/[lang]/blog/[category]/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MetadataRoute } from 'next'
import { getArticleSections } from '@/services/datocms'
import { CategoryPageProps } from './page'

export default async function sitemap(
props: CategoryPageProps
): Promise<MetadataRoute.Sitemap> {
const {
params: { lang }
} = props
let sections = [];
try {
sections = await getArticleSections(lang);
} catch (error) {
return [];
}

const categories = sections.map(section => section.slug)
return categories.map(category => ({
url: `https://${process.env.VERCEL_URL}/${lang}/blog/${category}`,
lastModified: new Date()
}))
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/blog/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/blog`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/in/early-access/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/in/early-access`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/learn/batch-auctions/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/learn/batch-auctions`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/learn/developers/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/learn/developers`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/learn/media/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/learn/media`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/learn/security/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/learn/security`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/learn/tokenization/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/learn/tokenization`,
lastModified: new Date()
}
]
}
13 changes: 13 additions & 0 deletions apps/webapp/app/(routes)/[lang]/legal/privacy/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CommonPageProps } from '@/types/routing.type'
import { MetadataRoute } from 'next'

export default async function sitemap({
params
}: CommonPageProps): Promise<MetadataRoute.Sitemap> {
return [
{
url: `https://${process.env.VERCEL_URL}/${params.lang}/legal/privacy`,
lastModified: new Date()
}
]
}
Loading

0 comments on commit 31a5ce9

Please sign in to comment.