@@ -2,6 +2,7 @@ import { PortableText, PortableTextComponents } from '@portabletext/react'
22import type { PortableTextBlock } from '@portabletext/types'
33import { Image } from 'sanity'
44
5+ import HighlightCode from '@/components/shared/HighlightCode'
56import ImageBox from '@/components/shared/ImageBox'
67import { TimelineSection } from '@/components/shared/TimelineSection'
78
@@ -13,10 +14,39 @@ export function CustomPortableText({
1314 value : PortableTextBlock [ ]
1415} ) {
1516 const components : PortableTextComponents = {
17+ list : {
18+ bullet : ( { children} ) => < ul className = "mt-xl list-disc" > { children } </ ul > ,
19+ number : ( { children} ) => < ol className = "mt-lg list-decimal" > { children } </ ol > ,
20+ } ,
1621 block : {
1722 normal : ( { children } ) => {
1823 return < p className = { paragraphClasses } > { children } </ p >
1924 } ,
25+ h1 : ( { children } ) => {
26+ return < h1 className = "text-4xl font-serif font-bold" > { children } </ h1 >
27+ } ,
28+ h2 : ( { children } ) => {
29+ return < h2 className = "text-3xl font-serif font-bold" > { children } </ h2 >
30+ } ,
31+ h3 : ( { children } ) => {
32+ return < h3 className = "text-2xl font-serif font-bold" > { children } </ h3 >
33+ } ,
34+ h4 : ( { children } ) => {
35+ return < h4 className = "text-xl font-serif font-bold" > { children } </ h4 >
36+ } ,
37+ h5 : ( { children } ) => {
38+ return < h5 className = "text-lg font-serif font-bold" > { children } </ h5 >
39+ } ,
40+ h6 : ( { children } ) => {
41+ return < h6 className = "text-base font-serif font-bold" > { children } </ h6 >
42+ } ,
43+ blockquote : ( { children } ) => {
44+ return (
45+ < blockquote className = "border-l-4 border-neutral-500 pl-1" >
46+ { children }
47+ </ blockquote >
48+ )
49+ } ,
2050 } ,
2151 marks : {
2252 link : ( { children, value } ) => {
@@ -30,6 +60,10 @@ export function CustomPortableText({
3060 </ a >
3161 )
3262 } ,
63+ em : ( { children} ) => < em className = "text-gray-600 font-semibold" > { children } </ em > ,
64+ strong : ( { children} ) => < strong className = "font-semibold" > { children } </ strong > ,
65+ strikeThrough : ( { children} ) => < del className = "line-through" > { children } </ del > ,
66+ underline : ( { children} ) => < u className = "underline" > { children } </ u > ,
3367 } ,
3468 types : {
3569 image : ( {
@@ -38,7 +72,7 @@ export function CustomPortableText({
3872 value : Image & { alt ?: string ; caption ?: string }
3973 } ) => {
4074 return (
41- < div className = "my-6 space-y-2 " >
75+ < div className = "my-1 space-y-1 max-w-[60rem] mx-auto " >
4276 < ImageBox
4377 image = { value }
4478 alt = { value . alt }
@@ -56,6 +90,13 @@ export function CustomPortableText({
5690 const { items } = value || { }
5791 return < TimelineSection timelines = { items } />
5892 } ,
93+ code : ( { value } ) => {
94+ const { code, language } = value || { }
95+
96+ return (
97+ < HighlightCode code = { code } language = { language } />
98+ )
99+ } ,
59100 } ,
60101 }
61102
0 commit comments