Skip to content

Commit b510fd6

Browse files
Martin Berg Alstadolav223
andauthored
Fjernet alt Markdown relatert (#136)
* Fjernet Markdown relatert. Npm-pakker referanser i schema hjelpefunksjoner og andre referanser Endret deprecated import desktool til structuretool. https://www.sanity.io/help/desk-is-now-structure#da1127c8a572 * update with main --------- Co-authored-by: Stein Olav Frey <steinolav98@hotmail.no>
1 parent 5809282 commit b510fd6

13 files changed

Lines changed: 117 additions & 881 deletions

File tree

app/(root)/arrangement/[slug]/page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import { notFound } from "next/navigation"
55
import SingleInfoCard from "@/components/cards/singleInfoCard"
66
import { type Metadata } from "next"
77
import { createEvent } from "ics"
8-
import { getDescription, getEventTypeLabel } from "@/sanity/lib/utils"
8+
import { getEventTypeLabel } from "@/sanity/lib/utils"
99
import type { RootEvent } from "@/sanity/types"
1010
import IcsButton from "@/components/buttons/icsButton"
1111
import { Date, Time } from "@/components/date"
12+
import { toPlainText } from "@portabletext/react"
1213

1314
interface Params {
1415
slug: string
@@ -34,7 +35,6 @@ const EventPage: AsyncPage<Params> = async ({ params }) => {
3435
return (
3536
<SingleInfoCard
3637
title={event.title}
37-
description={event.description}
3838
descriptionBlock={event.description_block}
3939
image={event.hero_image}
4040
maxParticipants={
@@ -85,7 +85,9 @@ export async function generateMetadata({ params }: PageProps<Params>): Promise<M
8585

8686
return {
8787
title: `${event.title} | Root Linjeforening`,
88-
description: await getDescription(event),
88+
description: event.description_block
89+
? toPlainText(event.description_block)
90+
: "Arrangement arrangert av Root Linjeforening",
8991
}
9092
}
9193

@@ -96,15 +98,15 @@ export async function generateMetadata({ params }: PageProps<Params>): Promise<M
9698
* @returns En string på ics format
9799
* @see https://www.npmjs.com/package/ics
98100
*/
99-
async function createIcsEvent(event: RootEvent): Promise<string | undefined> {
101+
function createIcsEvent(event: RootEvent): string | undefined {
100102
let icsEvent: string | undefined = undefined
101103
const end = event.end_time
102104
? { end: toDateTuple(event.end_time) }
103105
: { duration: { hours: defaultEventDuration } }
104106
createEvent(
105107
{
106108
title: event.title,
107-
description: await getDescription(event),
109+
description: event.description_block ? toPlainText(event.description_block) : "",
108110
location: event.address_text,
109111
start: toDateTuple(event.start_time),
110112
...end,

app/(root)/stilling/[slug]/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { notFound } from "next/navigation"
44
import SingleInfoCard from "@/components/cards/singleInfoCard"
55
import { type Metadata } from "next"
66
import { Date } from "@/components/date"
7-
import { getDescription } from "@/sanity/lib/utils"
7+
import { toPlainText } from "@portabletext/react"
88

99
interface Params {
1010
slug: string
@@ -25,7 +25,6 @@ const JobAdvertPage: AsyncPage<Params> = async ({ params }) => {
2525
return (
2626
<SingleInfoCard
2727
title={ad.title}
28-
description={ad.description}
2928
descriptionBlock={ad.description_block}
3029
image={ad.image}
3130
maxParticipants={
@@ -71,6 +70,6 @@ export async function generateMetadata(props: PageProps<Params>): Promise<Metada
7170

7271
return {
7372
title: `${ad.title} | Root Linjeforening`,
74-
description: await getDescription(ad),
73+
description: ad.description_block ? toPlainText(ad.description_block) : "Stillingsannonse",
7574
}
7675
}

components/cards/singleInfoCard.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { AttendeesIcon, bigIconSize, MapIcon } from "@/components/icons/icon"
22
import { ExternalLinkButton } from "@/components/buttons/button"
3-
import Markdown from "@/components/markdown"
43
import { ExternalLink } from "@/components/link"
5-
import type { MarkdownString, SanityImageObject } from "@/sanity/types"
4+
import type { SanityImageObject } from "@/sanity/types"
65
import { PortableText } from "@portabletext/react"
76
import { components } from "@/sanity/lib/portabletext"
87
import type { TypedObject } from "sanity"
@@ -11,7 +10,6 @@ import ImageViewer from "@/components/imageViewer"
1110
interface SingleInfoCardProps extends ChildProps {
1211
image?: SanityImageObject
1312
title?: string
14-
description?: MarkdownString
1513
descriptionBlock?: TypedObject | TypedObject[]
1614
addressText?: string
1715
addressUrl?: string
@@ -24,7 +22,6 @@ interface SingleInfoCardProps extends ChildProps {
2422
* En komponent som viser et enkelt arrangement, stillingsannonse eller innlegg.
2523
* @param image Bildet som vises på toppen av kortet. Bør være i 16:7 format. Hvis ikke vil bildet bli beskåret i høyden. Dersom bildet er for lavt kan det bli beskåret i bredden.
2624
* @param title Tittelen på kortet
27-
* @param description Beskrivelsen på kortet i Markdown format
2825
* @param descriptionBlock Beskrivelsen på kortet i PortableText format
2926
* @param addressText Teksten som vises for adressen. Dersom denne ikke er satt vil ikke adressekomponenten vises.
3027
* @param addressUrl URLen til adressen. Dersom den er satt vil adressen bli en lenke.
@@ -37,7 +34,6 @@ interface SingleInfoCardProps extends ChildProps {
3734
const SingleInfoCard: Component<SingleInfoCardProps> = ({
3835
image,
3936
title,
40-
description,
4137
descriptionBlock,
4238
addressText,
4339
addressUrl,
@@ -63,12 +59,10 @@ const SingleInfoCard: Component<SingleInfoCardProps> = ({
6359
{children}
6460
</div>
6561

66-
{descriptionBlock ? (
62+
{descriptionBlock && (
6763
<div className={"prose my-5 max-w-none"}>
6864
<PortableText value={descriptionBlock} components={components} />
6965
</div>
70-
) : (
71-
<Markdown className={"prose my-5 max-w-none"} markdown={description} />
7266
)}
7367
</div>
7468
{buttonUrl && (

components/markdown.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

components/omOss/InfoPageContent.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ export const InfoPageContent: Component<{
2424
<div>
2525
{infoSider.map((side: InfoSide) => (
2626
<section id={side._id} key={side._id} className={"mb-16 scroll-mt-44"}>
27-
<SingleInfoCard
28-
image={side.image}
29-
description={side.info}
30-
descriptionBlock={side.info_block}
31-
/>
27+
<SingleInfoCard image={side.image} descriptionBlock={side.info_block} />
3228
</section>
3329
))}
3430
</div>

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
"react": "^18.2.0",
2828
"react-dom": "^18.2.0",
2929
"react-use-keypress": "^1.3.1",
30-
"remark": "^15.0.1",
31-
"remark-html": "^16.0.1",
3230
"sanity": "^3.27.1",
33-
"sanity-plugin-markdown": "^4.1.0",
34-
"strip-markdown": "^6.0.0",
3531
"styled-components": "^5.3.11"
3632
},
3733
"devDependencies": {

0 commit comments

Comments
 (0)