Skip to content

Commit

Permalink
fix: Adjust markdown links to correct level (#255)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
  • Loading branch information
lachlancollins and TkDodo authored Jul 19, 2024
1 parent 8298cbb commit 1f8f8dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/components/MarkdownLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { Link } from '@tanstack/react-router'
import type { HTMLProps } from 'react'

export function MarkdownLink(props: HTMLProps<HTMLAnchorElement>) {
if ((props as { href: string }).href?.startsWith('http')) {
if (props.href?.startsWith('http')) {
return <a {...props} />
}

const relativeHref = props.href?.replace(/([A-Za-z][A-Za-z/_-]+).md/, '../$1')

return (
<Link
to={props.href as any}
to={relativeHref}
params={{}}
{...props}
preload={undefined}
Expand Down

0 comments on commit 1f8f8dc

Please sign in to comment.