Skip to content

Commit f72dba0

Browse files
committed
blockquoteではなくasideに変更、ネスト対応
1 parent aa640f8 commit f72dba0

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

app/markdown/markdown.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
DaisySuccessIcon,
1717
DaisyWarningIcon,
1818
} from "@/daisyAlertIcon";
19+
import { CSSProperties } from "react";
1920

2021
export function StyledMarkdown(props: {
2122
content: string;
@@ -68,6 +69,20 @@ const baseComponents: Components = {
6869
hr: () => null,
6970
blockquote: ({ node, className, children, ...props }) => (
7071
<blockquote
72+
className={clsx("alert", className, "mx-2 my-2", "flex")}
73+
{...props}
74+
>
75+
<div
76+
// <p>がmx-2 my-2を設定するので、その分広げて相殺
77+
className="flex-1 w-full -m-2"
78+
>
79+
{children}
80+
</div>
81+
</blockquote>
82+
),
83+
aside: ({ node, className, children, ...props }) => (
84+
// remarkGitHubAlerts.ts でalertをasideタグにしている
85+
<aside
7186
className={clsx(
7287
"alert",
7388
className,
@@ -86,9 +101,15 @@ const baseComponents: Components = {
86101
) : className?.includes("alert-error") ? (
87102
<DaisyErrorIcon />
88103
) : null}
89-
{/* <p>がmx-2 my-2を設定するので、その分広げて相殺 */}
90-
<div className="flex-1 w-full -m-2 self-center">{children}</div>
91-
</blockquote>
104+
<div
105+
// <p>がmx-2 my-2を設定するので、その分広げて相殺
106+
className="flex-1 w-full -m-2 self-center"
107+
// alertネスト対応
108+
style={{ "--alert-color": "initial" } as CSSProperties}
109+
>
110+
{children}
111+
</div>
112+
</aside>
92113
),
93114
pre: ({ children }) => children,
94115
code: (props) => <AutoCodeBlock interactive={false} {...props} />,

app/markdown/remarkGithubAlerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Option = {
5656
*/
5757
export const remarkAlert: Plugin<[Option?], Root> = ({
5858
legacyTitle = false,
59-
tagName = "blockquote",
59+
tagName = "aside",
6060
classNames = "",
6161
} = {}) => {
6262
return (tree) => {

0 commit comments

Comments
 (0)