|
1 | | -'use client'; |
2 | | - |
3 | | -import React from 'react'; |
4 | | -import { useParams } from 'next/navigation'; |
| 1 | +import { Metadata } from 'next'; |
5 | 2 | import { graphql } from '@/gql'; |
6 | | -import { useQuery } from '@tanstack/react-query'; |
7 | 3 |
|
8 | 4 | import { GraphQL } from '@/lib/api'; |
9 | | -import { Loading } from '@/components/loading'; |
10 | | -import ProfileDetails from '../../components/ProfileDetails'; |
11 | | -import { Spinner } from 'opub-ui'; |
12 | | -import SidebarCard from '../../components/SidebarCard'; |
13 | | -import BreadCrumbs from '@/components/BreadCrumbs'; |
| 5 | +import { generatePageMetadata } from '@/lib/utils'; |
| 6 | +import OrgPageClient from './OrgPageClient'; |
14 | 7 |
|
15 | | -const orgInfoQuery: any = graphql(` |
16 | | - query organizationData($id: String!) { |
| 8 | +const orgDataQuery = graphql(` |
| 9 | + query orgData($id: String!) { |
17 | 10 | organization(id: $id) { |
18 | 11 | id |
19 | | - created |
20 | | - description |
21 | | - contributedSectorsCount |
22 | | - location |
23 | | - twitterProfile |
24 | | - githubProfile |
25 | 12 | name |
| 13 | + description |
26 | 14 | logo { |
27 | 15 | url |
28 | 16 | } |
29 | | - publishedUseCasesCount |
30 | | - publishedDatasetsCount |
31 | | - linkedinProfile |
32 | 17 | } |
33 | 18 | } |
34 | 19 | `); |
35 | 20 |
|
36 | | -const OrgPage = () => { |
37 | | - const params = useParams(); |
38 | | - const organizationInfo: any = useQuery([`${params.publisherSlug}`], () => |
39 | | - GraphQL( |
40 | | - orgInfoQuery, |
41 | | - { |
42 | | - // Entity Headers if present |
43 | | - }, |
44 | | - { id: params.organizationSlug } |
45 | | - ) |
46 | | - ); |
| 21 | +export async function generateMetadata({ |
| 22 | + params, |
| 23 | +}: { |
| 24 | + params: { organizationSlug: string }; |
| 25 | +}): Promise<Metadata> { |
| 26 | + const data = await GraphQL(orgDataQuery, {}, { id: params.organizationSlug }); |
47 | 27 |
|
48 | | - return ( |
49 | | - <main className="bg-primaryBlue"> |
50 | | - <BreadCrumbs |
51 | | - data={[ |
52 | | - { href: '/', label: 'Home' }, |
53 | | - { href: '/publishers', label: 'Publishers' }, |
54 | | - { |
55 | | - href: '#', |
56 | | - label: `${organizationInfo?.data?.organization?.name || ''} `, |
57 | | - }, |
58 | | - ]} |
59 | | - /> |
60 | | - { |
61 | | - <div className="container py-10 text-surfaceDefault"> |
62 | | - <div className="flex flex-wrap gap-10 lg:flex-nowrap"> |
63 | | - <div className="w-full lg:w-1/4"> |
64 | | - {organizationInfo?.isLoading ? ( |
65 | | - <div className="m-4 flex justify-center rounded-2 bg-surfaceDefault p-4"> |
66 | | - <Spinner color="highlight" /> |
67 | | - </div> |
68 | | - ) : ( |
69 | | - <SidebarCard data={organizationInfo?.data?.organization} type={'organization'}/> |
70 | | - )} |
71 | | - </div> |
72 | | - <div className="w-full"> |
73 | | - {organizationInfo?.isLoading ? ( |
74 | | - <div className="m-4 flex justify-center rounded-2 bg-surfaceDefault p-4"> |
75 | | - <Spinner color="highlight" /> |
76 | | - </div> |
77 | | - ) : ( |
78 | | - <ProfileDetails data={organizationInfo?.data?.organization} type={'organization'}/> |
| 28 | + const org = data.organization; |
79 | 29 |
|
80 | | - )} |
81 | | - </div> |
82 | | - </div> |
83 | | - </div> |
84 | | - } |
85 | | - </main> |
86 | | - ); |
87 | | -}; |
| 30 | + return generatePageMetadata({ |
| 31 | + title: `${org?.name} | Publisher on CivicDataSpace`, |
| 32 | + description: |
| 33 | + org?.description || 'Explore datasets and use cases by this publisher.', |
| 34 | + keywords: [ |
| 35 | + 'CivicDataSpace Publisher', |
| 36 | + 'Open Data Contributor', |
| 37 | + 'Use Case Publisher', |
| 38 | + 'Dataset Publisher', |
| 39 | + 'CivicTech', |
| 40 | + 'Open Government Data', |
| 41 | + ], |
| 42 | + openGraph: { |
| 43 | + title: `${org?.name} | Publisher on CivicDataSpace`, |
| 44 | + description: |
| 45 | + org?.description || 'Explore datasets and use cases by this publisher.', |
| 46 | + type: 'profile', |
| 47 | + siteName: 'CivicDataSpace', |
| 48 | + url: `${process.env.NEXT_PUBLIC_PLATFORM_URL}/publishers/${params.organizationSlug}`, |
| 49 | + image: org?.logo?.url |
| 50 | + ? `${process.env.NEXT_PUBLIC_BACKEND_URL}/${org.logo.url}` |
| 51 | + : `${process.env.NEXT_PUBLIC_PLATFORM_URL}/og.png`, |
| 52 | + locale: 'en_US', |
| 53 | + }, |
| 54 | + }); |
| 55 | +} |
88 | 56 |
|
89 | | -export default OrgPage; |
| 57 | +export default function OrgPage({ |
| 58 | + params, |
| 59 | +}: { |
| 60 | + params: { organizationSlug: string }; |
| 61 | +}) { |
| 62 | + return <OrgPageClient organizationSlug={params.organizationSlug} />; |
| 63 | +} |
0 commit comments