From 4f8e7b74fa82df0df6896158cd2cf5405dee2baf Mon Sep 17 00:00:00 2001 From: liliana <liliana.sanfilippo@uni-bielefeld.de> Date: Fri, 6 Sep 2024 12:27:53 +0200 Subject: [PATCH] idtext --- src/components/headings.tsx | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/components/headings.tsx b/src/components/headings.tsx index 01e110cd..583d6a0e 100644 --- a/src/components/headings.tsx +++ b/src/components/headings.tsx @@ -1,3 +1,4 @@ +import { stringToSlug } from "../utils"; export function Hhopp({text}:{text: string}){ const arr = []; @@ -25,9 +26,16 @@ export function Hsmoke({text}:{text: string}){ ) } -export function H1({text}:{text: string}){ +export function H1({text, id}:{text: string, id?: string}){ + var idtext: string; + if (id) { + idtext = id; + } + else{ + idtext = stringToSlug(text); + } return( - <div className="row hone"> + <div id={idtext} className="row hone"> <svg width="100%" height="100%"> <text x="0%" y="60%"> {text} @@ -38,20 +46,34 @@ export function H1({text}:{text: string}){ } -export function H2({text, id}:{text: string, id: string}){ +export function H2({text, id}:{text: string, id?: string}){ + var idtext: string; + if (id) { + idtext = id; + } + else{ + idtext = stringToSlug(text); + } return( <div> - <h2 id={id}>{text}</h2> + <h2 id={idtext}>{text}</h2> <hr/> </div> ) } -export function H3({text, id}:{text: string, id: string}){ +export function H3({text, id}:{text: string, id?: string}){ + var idtext: string; + if (id) { + idtext = id; + } + else{ + idtext = stringToSlug(text); + } return( <div> - <h3 id={id}>{text}</h3> + <h3 id={idtext}>{text}</h3> </div> ) -- GitLab