Skip to content

Commit 3a37333

Browse files
feat: make links in event descriptions clickable
1 parent a32e413 commit 3a37333

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

components/events-section.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import Linkify from 'linkify-react';
34
import { useCallback, useEffect, useState } from 'react';
45

56
import { MainSection } from '@/components/sections';
@@ -86,6 +87,18 @@ export function EventsSection() {
8687
return eventDate <= oneWeekFromNow;
8788
};
8889

90+
const linkifyOptions = {
91+
target: '_blank',
92+
rel: 'noopener noreferrer',
93+
format: (value: string, type: string) => {
94+
if (type === 'url') {
95+
return value.replace(/^https?:\/\/(www\.)?/, '').replace(/\/$/, '');
96+
}
97+
return value;
98+
},
99+
className: 'text-primary hover:text-primary/80 underline',
100+
};
101+
89102
const Header = () => {
90103
return (
91104
<div className="text-center mb-12">
@@ -163,7 +176,9 @@ export function EventsSection() {
163176
</div>
164177
<CardTitle className="text-lg">{event.title}</CardTitle>
165178
<CardDescription className={'' /* no line-clamp */}>
166-
{event.description}
179+
<Linkify options={linkifyOptions}>
180+
{event.description}
181+
</Linkify>
167182
</CardDescription>
168183
</CardHeader>
169184
<div className="flex-grow" />

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"clsx": "^2.1.1",
2121
"embla-carousel-autoplay": "^8.6.0",
2222
"embla-carousel-react": "^8.6.0",
23+
"linkify-react": "^4.3.2",
2324
"next": "16.0.10",
2425
"next-sitemap": "^4.2.3",
2526
"node-ical": "^0.22.0",

package.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildNpmPackage {
88

99
src = ./.;
1010
# needs to be updated everytime you update npm dependencies
11-
npmDepsHash = "sha256-AiivLghXPixVPBe4rjngpDppcOz8tamOqAmTiF+zegM=";
11+
npmDepsHash = "sha256-MRBC45iq5A4H2kx13qq/bSo+x9Pu2B98y5cpWlSq+5Y=";
1212

1313
# install fonts
1414
preBuild = ''

0 commit comments

Comments
 (0)