docs: hide colon when a note's title has a punctuation (#12205)

This commit is contained in:
Shahed Nasser
2025-04-16 17:23:10 +03:00
committed by GitHub
parent d98b560f26
commit 6c59d3fe6f

View File

@@ -10,6 +10,8 @@ type StringInfo = {
type NoteLayoutProps = NoteProps
const PUNCTIONATIONS = [".", ":", ";", ",", "!", "?"]
export const NoteLayout = ({
type,
title,
@@ -84,6 +86,12 @@ export const NoteLayout = ({
}
}, [children, forceMultiline])
const showColon = useMemo(() => {
const lastChar = title?.charAt(title.length - 1) || ""
return !PUNCTIONATIONS.includes(lastChar)
}, [title])
return (
<div
className={clsx(
@@ -107,7 +115,8 @@ export const NoteLayout = ({
<div className="flex-1">
<div className="text-small text-medusa-fg-subtle [&_ol]:!mb-0 [&_ul]:!mb-0">
<span className={clsx("text-small-plus text-medusa-fg-base")}>
{title}:&nbsp;
{title}
{showColon ? ":" : ""}&nbsp;
</span>
{allStringChildren && (
<MarkdownContent