Skip to content

Commit e9a687f

Browse files
Merge pull request #372 from CivicDataLab/fix/required-indicator
description and collabrative card
2 parents 7b8657c + a69c1c8 commit e9a687f

8 files changed

Lines changed: 33 additions & 59 deletions

File tree

app/[locale]/(user)/collaboratives/CollaborativesListingClient.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ const CollaborativesListingClient = () => {
300300
title={collaborative.title || ''}
301301
variation="collapsed"
302302
iconColor="warning"
303+
imageUrl={`${process.env.NEXT_PUBLIC_BACKEND_URL}/${collaborative.logo?.path.replace('/code/files/', '')}`}
303304
metadataContent={[
304305
{
305306
icon: Icons.calendar as any,
@@ -343,7 +344,7 @@ const CollaborativesListingClient = () => {
343344
label: 'Published by',
344345
},
345346
]}
346-
description={`rest ${stripMarkdown(collaborative.summary || '')}`}
347+
description={stripMarkdown(collaborative.summary || '')}
347348
/>
348349
)
349350
)}

app/[locale]/(user)/collaboratives/[collaborativeSlug]/CollaborativeDetailsClient.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import BreadCrumbs from '@/components/BreadCrumbs';
2020
import { Icons } from '@/components/icons';
2121
import JsonLd from '@/components/JsonLd';
2222
import { Loading } from '@/components/loading';
23+
import { stripMarkdown } from '../../search/components/UnifiedListingComponent';
2324
import PrimaryDetails from '../components/Details';
2425
import Metadata from '../components/Metadata';
2526

@@ -476,7 +477,7 @@ const CollaborativeDetailClient = () => {
476477

477478
const commonProps = {
478479
title: useCase.title || '',
479-
description: useCase.summary || '',
480+
description: stripMarkdown(useCase.summary || ''),
480481
metadataContent: MetadataContent,
481482
tag: useCase.tags?.map((t: any) => t.value) || [],
482483
footerContent: FooterContent,
@@ -558,7 +559,7 @@ const CollaborativeDetailClient = () => {
558559
label: 'Published by',
559560
},
560561
]}
561-
description={dataset.description || ''}
562+
description={stripMarkdown(dataset.description || '')}
562563
/>
563564
))}
564565
</div>

app/[locale]/(user)/components/Content.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use client';
22

3-
import { graphql } from '@/gql';
4-
import { useQuery } from '@tanstack/react-query';
53
import Image from 'next/image';
64
import Link from 'next/link';
75
import { useRouter } from 'next/navigation';
6+
import { graphql } from '@/gql';
7+
import { useTourTrigger } from '@/hooks/use-tour-trigger';
8+
import { useQuery } from '@tanstack/react-query';
89
import { SearchInput, Spinner, Text } from 'opub-ui';
910

10-
import { useTourTrigger } from '@/hooks/use-tour-trigger';
1111
import { GraphQL } from '@/lib/api';
1212
import { cn } from '@/lib/utils';
1313
import Styles from '../page.module.scss';
@@ -24,13 +24,12 @@ const statsInfo: any = graphql(`
2424
}
2525
`);
2626

27-
2827
export const Content = () => {
2928
const router = useRouter();
30-
29+
3130
// Enable tour for first-time users
3231
useTourTrigger(true, 1500);
33-
32+
3433
const Stats: { data: any; isLoading: any } = useQuery([`statsDetails`], () =>
3534
GraphQL(statsInfo, {}, [])
3635
);
@@ -64,17 +63,25 @@ export const Content = () => {
6463
},
6564
];
6665

67-
6866
return (
6967
<main className="container py-10 md:px-8 lg:py-20">
7068
<div className="flex justify-around gap-8 px-4 md:px-12 lg:px-12">
7169
<div className="flex flex-col gap-11 lg:w-[60%]">
7270
<div className="flex flex-col gap-2">
73-
<Text variant="heading3xl" color="onBgDefault" className='text-textOnBGDefault1'>
71+
<Text
72+
variant="heading3xl"
73+
color="onBgDefault"
74+
className="text-textOnBGDefault1"
75+
>
7476
An Open-Source Platform for Collaborative Data-Driven Change
7577
</Text>
76-
<Text variant="headingLg" color="onBgDefault" className='text-textOnBGDefault2'>
77-
Share datasets, knowledge resources, and AI use-cases for data changemakers.
78+
<Text
79+
variant="headingLg"
80+
color="onBgDefault"
81+
className="text-textOnBGDefault2"
82+
>
83+
Share datasets, knowledge resources, and AI use-cases for data
84+
changemakers.
7885
</Text>
7986
</div>
8087
<div className="w-full" data-tour="search-bar">
@@ -115,7 +122,7 @@ export const Content = () => {
115122
<Text
116123
color="onBgDefault"
117124
fontWeight="semibold"
118-
className="uppercase text-xs text-textSurfaceStats"
125+
className="text-xs uppercase text-textSurfaceStats"
119126
>
120127
{item.label}
121128
</Text>
@@ -124,7 +131,7 @@ export const Content = () => {
124131
))}
125132
</div>
126133
)}
127-
134+
128135
{/* <div className="flex flex-wrap gap-4">
129136
{Sectors.map((item, index) => (
130137
<div key={index}>

app/[locale]/(user)/components/ListingComponent.tsx

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,46 +28,7 @@ import {
2828
} from '@/components/loading';
2929
import Filter from '../datasets/components/FIlter/Filter';
3030
import Styles from '../datasets/dataset.module.scss';
31-
32-
// Helper function to strip markdown and HTML tags for card preview
33-
const stripMarkdown = (markdown: string): string => {
34-
if (!markdown) return '';
35-
return (
36-
markdown
37-
// Remove code blocks first (before other replacements)
38-
.replace(/```[\s\S]*?```/g, '')
39-
// Remove inline code
40-
.replace(/`([^`]+)`/g, '$1')
41-
// Remove images
42-
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '$1')
43-
// Remove links
44-
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
45-
// Remove headers
46-
.replace(/^#{1,6}\s+/gm, '')
47-
// Remove bold
48-
.replace(/\*\*([^*]+)\*\*/g, '$1')
49-
.replace(/__([^_]+)__/g, '$1')
50-
// Remove italic
51-
.replace(/\*([^*]+)\*/g, '$1')
52-
.replace(/_([^_]+)_/g, '$1')
53-
// Remove strikethrough
54-
.replace(/~~([^~]+)~~/g, '$1')
55-
// Remove blockquotes
56-
.replace(/^\s*>\s+/gm, '')
57-
// Remove horizontal rules
58-
.replace(/^(-{3,}|_{3,}|\*{3,})$/gm, '')
59-
// Remove list markers
60-
.replace(/^\s*[-*+]\s+/gm, '')
61-
.replace(/^\s*\d+\.\s+/gm, '')
62-
// Remove HTML tags
63-
.replace(/<[^>]*>/g, '')
64-
// Remove extra whitespace and newlines
65-
.replace(/\n\s*\n/g, '\n')
66-
.replace(/\n/g, ' ')
67-
.replace(/\s+/g, ' ')
68-
.trim()
69-
);
70-
};
31+
import { stripMarkdown } from '../search/components/UnifiedListingComponent';
7132

7233
// Interfaces
7334
interface Bucket {

app/[locale]/(user)/datasets/[datasetIdentifier]/components/SimilarDatasets/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useParams } from 'next/navigation';
2+
import { stripMarkdown } from '@/app/[locale]/(user)/search/components/UnifiedListingComponent';
23
import { graphql } from '@/gql';
34
import { useQuery } from '@tanstack/react-query';
45
import {
@@ -123,7 +124,7 @@ const SimilarDatasets: React.FC = () => {
123124
{' '}
124125
<Card
125126
title={item.title}
126-
description={item.description}
127+
description={stripMarkdown(item.description || '')}
127128
metadataContent={[
128129
{
129130
icon: Icons.calendar as any,

app/[locale]/(user)/publishers/components/Datasets.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Card, Icon, Spinner, Text } from 'opub-ui';
66
import { GraphQL } from '@/lib/api';
77
import { cn } from '@/lib/utils';
88
import { Icons } from '@/components/icons';
9+
import { stripMarkdown } from '../../search/components/UnifiedListingComponent';
910

1011
const userPublishedDatasetsDoc: any = graphql(`
1112
query userPublishedDatasetsList($userId: ID!) {
@@ -152,7 +153,7 @@ const Datasets = ({ type }: { type: 'organization' | 'Publisher' }) => {
152153
]}
153154
key={index}
154155
title={item.title}
155-
description={item.description}
156+
description={stripMarkdown(item.description || '')}
156157
metadataContent={[
157158
{
158159
icon: Icons.calendar as any,

app/[locale]/(user)/publishers/components/UseCases.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Card, Icon, Spinner, Text } from 'opub-ui';
77
import { GraphQL } from '@/lib/api';
88
import { cn, formatDate } from '@/lib/utils';
99
import { Icons } from '@/components/icons';
10+
import { stripMarkdown } from '../../search/components/UnifiedListingComponent';
1011

1112
const userPublishedUseCasesDoc: any = graphql(`
1213
query userPublishedUseCasesList($userId: ID!) {
@@ -180,7 +181,7 @@ const UseCases = ({ type }: { type: 'organization' | 'Publisher' }) => {
180181
label: 'Published by',
181182
},
182183
]}
183-
description={item.summary}
184+
description={stripMarkdown(item.summary || '')}
184185
iconColor="warning"
185186
variation={'collapsed'}
186187
/>

app/[locale]/(user)/usecases/[useCaseSlug]/UsecaseDetailsClient.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import BreadCrumbs from '@/components/BreadCrumbs';
1616
import { Icons } from '@/components/icons';
1717
import JsonLd from '@/components/JsonLd';
1818
import { Loading } from '@/components/loading';
19+
import { stripMarkdown } from '../../search/components/UnifiedListingComponent';
1920
import PrimaryDetails from '../components/Details';
2021
import Metadata from '../components/Metadata';
2122
import Dashboards from './Dashboards';
@@ -334,7 +335,7 @@ const UseCaseDetailClient = () => {
334335
label: 'Published by',
335336
},
336337
]}
337-
description={dataset.description || ''}
338+
description={stripMarkdown(dataset.description || '')}
338339
/>
339340
))}
340341
</div>

0 commit comments

Comments
 (0)