diff --git a/src/components/ui/Markdown.tsx b/src/components/ui/Markdown.tsx
index 58aad04..bb01b52 100644
--- a/src/components/ui/Markdown.tsx
+++ b/src/components/ui/Markdown.tsx
@@ -1,29 +1,154 @@
"use client";
-import React from "react";
+import React, { useState, useEffect } from "react";
+import { createPortal } from "react-dom";
import hljs from "highlight.js";
import "highlight.js/styles/github-dark.css";
+import {
+ Copy,
+ Check,
+ Info,
+ Lightbulb,
+ AlertTriangle,
+ AlertCircle,
+ X,
+ Link as LinkIcon,
+ Square,
+ CheckSquare
+} from "lucide-react";
-// Recursive inline markdown parser for Bold, Italic, Code, and Links
-export function parseInline(text: string, offset: number = 0): React.ReactNode[] {
+// Types for Callout / Alert
+export type CalloutType = "NOTE" | "TIP" | "IMPORTANT" | "WARNING" | "CAUTION";
+
+interface CalloutConfig {
+ icon: React.ElementType;
+ title: string;
+ borderColorClass: string;
+ bgColorClass: string;
+ textColorClass: string;
+ iconColorClass: string;
+}
+
+const CALLOUT_MAP: Record
= {
+ NOTE: {
+ icon: Info,
+ title: "NOTE",
+ borderColorClass: "border-sky-500/30 dark:border-sky-400/30",
+ bgColorClass: "bg-sky-500/10 dark:bg-sky-500/15",
+ textColorClass: "text-sky-900 dark:text-sky-200",
+ iconColorClass: "text-sky-600 dark:text-sky-400",
+ },
+ TIP: {
+ icon: Lightbulb,
+ title: "TIP",
+ borderColorClass: "border-emerald-500/30 dark:border-emerald-400/30",
+ bgColorClass: "bg-emerald-500/10 dark:bg-emerald-500/15",
+ textColorClass: "text-emerald-900 dark:text-emerald-200",
+ iconColorClass: "text-emerald-600 dark:text-emerald-400",
+ },
+ IMPORTANT: {
+ icon: Info,
+ title: "IMPORTANT",
+ borderColorClass: "border-purple-500/30 dark:border-purple-400/30",
+ bgColorClass: "bg-purple-500/10 dark:bg-purple-500/15",
+ textColorClass: "text-purple-900 dark:text-purple-200",
+ iconColorClass: "text-purple-600 dark:text-purple-400",
+ },
+ WARNING: {
+ icon: AlertTriangle,
+ title: "WARNING",
+ borderColorClass: "border-amber-500/30 dark:border-amber-400/30",
+ bgColorClass: "bg-amber-500/10 dark:bg-amber-500/15",
+ textColorClass: "text-amber-900 dark:text-amber-200",
+ iconColorClass: "text-amber-600 dark:text-amber-400",
+ },
+ CAUTION: {
+ icon: AlertCircle,
+ title: "CAUTION",
+ borderColorClass: "border-rose-500/30 dark:border-rose-400/30",
+ bgColorClass: "bg-rose-500/10 dark:bg-rose-500/15",
+ textColorClass: "text-rose-900 dark:text-rose-200",
+ iconColorClass: "text-rose-600 dark:text-rose-400",
+ },
+};
+
+// Copy button for code blocks with rich micro-interactions
+function CopyButton({ code }: { code: string }) {
+ const [copied, setCopied] = useState(false);
+
+ const handleCopy = async (e: React.MouseEvent) => {
+ e.stopPropagation();
+ try {
+ await navigator.clipboard.writeText(code);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ } catch (err) {
+ console.error("Failed to copy code: ", err);
+ }
+ };
+
+ return (
+
+ );
+}
+
+// Recursive inline markdown parser for Bold, Italic, Strikethrough, Highlight, Kbd, Code, Links, Task checkbox, Images
+export function parseInline(text: string, onImageClick?: (url: string, alt: string) => void, offset: number = 0): React.ReactNode[] {
if (!text) return [];
let minIndex = Infinity;
- let matchType: "bold" | "italic" | "code" | "link" | "image" | null = null;
+ let matchType: "image" | "bold" | "italic" | "strike" | "highlight" | "kbd" | "code" | "link" | "task_checked" | "task_unchecked" | null = null;
let matchedString = "";
- let matchData: string | { text: string; url: string } | null = null;
+ let matchData: any = null;
- // 0. Image ()
+ // 0. Task Checkboxes ([x] or [ ])
+ const taskCheckedRegex = /^\[([xX])\]\s+/;
+ const taskUncheckedRegex = /^\[\s\]\s+/;
+ const taskCheckedMatch = taskCheckedRegex.exec(text);
+ if (taskCheckedMatch && taskCheckedMatch.index < minIndex) {
+ minIndex = taskCheckedMatch.index;
+ matchType = "task_checked";
+ matchedString = taskCheckedMatch[0];
+ }
+ const taskUncheckedMatch = taskUncheckedRegex.exec(text);
+ if (taskUncheckedMatch && taskUncheckedMatch.index < minIndex) {
+ minIndex = taskUncheckedMatch.index;
+ matchType = "task_unchecked";
+ matchedString = taskUncheckedMatch[0];
+ }
+
+ // 1. Image ()
const imageRegex = /!\[([^\]]*)\]\(([^)]+)\)/;
const imageMatch = imageRegex.exec(text);
if (imageMatch && imageMatch.index < minIndex) {
minIndex = imageMatch.index;
matchType = "image";
matchedString = imageMatch[0];
- matchData = { text: imageMatch[1], url: imageMatch[2] };
+ matchData = { alt: imageMatch[1], url: imageMatch[2] };
}
- // 1. Bold (**text**)
+ // 2. Bold (**text**)
const boldRegex = /\*\*([^*]+)\*\*/;
const boldMatch = boldRegex.exec(text);
if (boldMatch && boldMatch.index < minIndex) {
@@ -33,7 +158,27 @@ export function parseInline(text: string, offset: number = 0): React.ReactNode[]
matchData = boldMatch[1];
}
- // 2. Italic (*text*)
+ // 3. Highlight (==text==)
+ const highlightRegex = /==([^=]+)==/;
+ const highlightMatch = highlightRegex.exec(text);
+ if (highlightMatch && highlightMatch.index < minIndex) {
+ minIndex = highlightMatch.index;
+ matchType = "highlight";
+ matchedString = highlightMatch[0];
+ matchData = highlightMatch[1];
+ }
+
+ // 4. Strikethrough (~~text~~)
+ const strikeRegex = /~~([^~]+)~~/;
+ const strikeMatch = strikeRegex.exec(text);
+ if (strikeMatch && strikeMatch.index < minIndex) {
+ minIndex = strikeMatch.index;
+ matchType = "strike";
+ matchedString = strikeMatch[0];
+ matchData = strikeMatch[1];
+ }
+
+ // 5. Italic (*text*)
const italicRegex = /\*([^*]+)\*/;
const italicMatch = italicRegex.exec(text);
if (italicMatch && italicMatch.index < minIndex) {
@@ -43,7 +188,17 @@ export function parseInline(text: string, offset: number = 0): React.ReactNode[]
matchData = italicMatch[1];
}
- // 3. Inline Code (`code`)
+ // 6. Inline Kbd (Key)
+ const kbdRegex = /([^<]+)<\/kbd>/i;
+ const kbdMatch = kbdRegex.exec(text);
+ if (kbdMatch && kbdMatch.index < minIndex) {
+ minIndex = kbdMatch.index;
+ matchType = "kbd";
+ matchedString = kbdMatch[0];
+ matchData = kbdMatch[1];
+ }
+
+ // 7. Inline Code (`code`)
const codeRegex = /`([^`]+)`/;
const codeMatch = codeRegex.exec(text);
if (codeMatch && codeMatch.index < minIndex) {
@@ -53,7 +208,7 @@ export function parseInline(text: string, offset: number = 0): React.ReactNode[]
matchData = codeMatch[1];
}
- // 4. Link ([text](url))
+ // 8. Link ([text](url))
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/;
const linkMatch = linkRegex.exec(text);
if (linkMatch && linkMatch.index < minIndex) {
@@ -72,27 +227,61 @@ export function parseInline(text: string, offset: number = 0): React.ReactNode[]
const result: React.ReactNode[] = [];
if (before) {
- result.push(...parseInline(before, offset));
+ result.push(...parseInline(before, onImageClick, offset));
}
const key = `${matchType}-${offset + minIndex}`;
- if (matchType === "bold" && typeof matchData === "string") {
+
+ if (matchType === "task_checked") {
result.push(
-
- {parseInline(matchData, offset + minIndex + 2)}
+
+
+
+ );
+ } else if (matchType === "task_unchecked") {
+ result.push(
+
+
+
+ );
+ } else if (matchType === "bold" && typeof matchData === "string") {
+ result.push(
+
+ {parseInline(matchData, onImageClick, offset + minIndex + 2)}
);
} else if (matchType === "italic" && typeof matchData === "string") {
result.push(
-
- {parseInline(matchData, offset + minIndex + 1)}
+
+ {parseInline(matchData, onImageClick, offset + minIndex + 1)}
);
+ } else if (matchType === "strike" && typeof matchData === "string") {
+ result.push(
+
+ {parseInline(matchData, onImageClick, offset + minIndex + 2)}
+
+ );
+ } else if (matchType === "highlight" && typeof matchData === "string") {
+ result.push(
+
+ {parseInline(matchData, onImageClick, offset + minIndex + 2)}
+
+ );
+ } else if (matchType === "kbd" && typeof matchData === "string") {
+ result.push(
+
+ {matchData}
+
+ );
} else if (matchType === "code" && typeof matchData === "string") {
result.push(
{matchData}
@@ -104,31 +293,46 @@ export function parseInline(text: string, offset: number = 0): React.ReactNode[]
href={matchData.url}
target="_blank"
rel="noopener noreferrer"
- className="text-gold hover:underline border-b border-gold/20 pb-0.5 transition-all font-sans text-[0.95em]"
+ className="text-(--accent-color) hover:text-(--accent-light-color) underline underline-offset-4 decoration-(--accent-color)/30 hover:decoration-(--accent-color) transition-colors font-sans font-medium text-[0.95em] inline-inline-flex items-center gap-0.5"
>
- {parseInline(matchData.text, offset + minIndex + 1)}
+ {parseInline(matchData.text, onImageClick, offset + minIndex + 1)}
);
- } else if (matchType === "image" && matchData && typeof matchData === "object" && "text" in matchData) {
+ } else if (matchType === "image" && matchData && typeof matchData === "object" && "url" in matchData) {
+ const { url, alt } = matchData;
result.push(
-
-
- {matchData.text && (
-
- {matchData.text}
-
+
+ onImageClick?.(url, alt)}
+ >
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+
+
+ 点击放大预览
+
+
+
+ {alt && (
+
+ {alt}
+
)}
-
+
);
}
if (after) {
- result.push(...parseInline(after, offset + minIndex + matchedString.length));
+ result.push(...parseInline(after, onImageClick, offset + minIndex + matchedString.length));
}
return result;
@@ -142,12 +346,12 @@ function parseTableLine(line: string): string[] {
if (trimmed.endsWith("|")) {
trimmed = trimmed.slice(0, -1);
}
- return trimmed.split("|").map(cell => cell.trim());
+ return trimmed.split("|").map((cell) => cell.trim());
}
function parseTableAligns(line: string): ("left" | "center" | "right")[] {
const parts = parseTableLine(line);
- return parts.map(part => {
+ return parts.map((part) => {
const trimmed = part.trim();
const left = trimmed.startsWith(":");
const right = trimmed.endsWith(":");
@@ -157,11 +361,26 @@ function parseTableAligns(line: string): ("left" | "center" | "right")[] {
});
}
-interface Block {
- type: "h1" | "h2" | "h3" | "h4" | "paragraph" | "blockquote" | "ul" | "ol" | "code" | "table";
+export interface Block {
+ type:
+ | "h1"
+ | "h2"
+ | "h3"
+ | "h4"
+ | "h5"
+ | "h6"
+ | "paragraph"
+ | "blockquote"
+ | "callout"
+ | "ul"
+ | "ol"
+ | "code"
+ | "table"
+ | "hr";
content?: string;
lines?: string[];
lang?: string;
+ calloutType?: CalloutType;
tableData?: {
headers: string[];
aligns: ("left" | "center" | "right")[];
@@ -185,15 +404,14 @@ export function parseBlocks(content: string): Block[] {
currentBlock.tableData!.rows.push(row);
continue;
} else {
- // Table ends
blocks.push(currentBlock);
currentBlock = null;
- i--; // re-process current line
+ i--; // re-process line
continue;
}
}
- // 0.5. Check Table Start
+ // 0.5. Table Start Check
if (line.includes("|") && i + 1 < lines.length) {
const nextLine = lines[i + 1];
const tableDividerRegex = /^\s*\|?\s*(:?-+:?)\s*(\|\s*(:?-+:?)\s*)*\|?\s*$/;
@@ -208,10 +426,10 @@ export function parseBlocks(content: string): Block[] {
tableData: {
headers,
aligns,
- rows: []
- }
+ rows: [],
+ },
};
- i++; // skip divider line
+ i++; // skip divider
continue;
}
}
@@ -219,11 +437,9 @@ export function parseBlocks(content: string): Block[] {
// 1. Code Block (```lang)
if (trimmed.startsWith("```")) {
if (currentBlock && currentBlock.type === "code") {
- // End of code block
blocks.push(currentBlock);
currentBlock = null;
} else {
- // Start of code block
if (currentBlock) {
blocks.push(currentBlock);
}
@@ -238,7 +454,49 @@ export function parseBlocks(content: string): Block[] {
continue;
}
- // 2. Unordered List (- or *)
+ // 2. Horizontal Rule (---, ***, ___)
+ if (/^(---|[*]{3,}|_{3,})$/.test(trimmed)) {
+ if (currentBlock) {
+ blocks.push(currentBlock);
+ currentBlock = null;
+ }
+ blocks.push({ type: "hr" });
+ continue;
+ }
+
+ // 3. Callout / Blockquote (>)
+ if (trimmed.startsWith(">")) {
+ const quoteContent = line.replace(/^\s*>\s?/, "");
+
+ // Check if this is the start of a Callout: > [!NOTE] etc.
+ const calloutMatch = quoteContent.match(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/i);
+
+ if (calloutMatch) {
+ if (currentBlock) {
+ blocks.push(currentBlock);
+ }
+ const calloutType = calloutMatch[1].toUpperCase() as CalloutType;
+ const remainingText = quoteContent.replace(/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i, "");
+ currentBlock = {
+ type: "callout",
+ calloutType,
+ lines: remainingText ? [remainingText] : [],
+ };
+ continue;
+ }
+
+ if (currentBlock && (currentBlock.type === "blockquote" || currentBlock.type === "callout")) {
+ currentBlock.lines!.push(quoteContent);
+ } else {
+ if (currentBlock) {
+ blocks.push(currentBlock);
+ }
+ currentBlock = { type: "blockquote", lines: [quoteContent] };
+ }
+ continue;
+ }
+
+ // 4. Unordered List (- or * or +)
const ulMatch = line.match(/^(\s*)([-*+])\s+(.*)$/);
if (ulMatch) {
const itemContent = ulMatch[3];
@@ -253,7 +511,7 @@ export function parseBlocks(content: string): Block[] {
continue;
}
- // 3. Ordered List (1., 2.)
+ // 5. Ordered List (1., 2.)
const olMatch = line.match(/^(\s*)(\d+)\.\s+(.*)$/);
if (olMatch) {
const itemContent = olMatch[3];
@@ -268,42 +526,29 @@ export function parseBlocks(content: string): Block[] {
continue;
}
- // 4. Blockquote (>)
- if (trimmed.startsWith(">")) {
- const quoteContent = line.replace(/^\s*>\s?/, "");
- if (currentBlock && currentBlock.type === "blockquote") {
- currentBlock.lines!.push(quoteContent);
- } else {
- if (currentBlock) {
- blocks.push(currentBlock);
- }
- currentBlock = { type: "blockquote", lines: [quoteContent] };
- }
- continue;
- }
-
- // 5. Headings
+ // 6. Headings (# H1 ~ ###### H6)
if (trimmed.startsWith("#")) {
- const hMatch = trimmed.match(/^(#{1,4})\s+(.*)$/);
+ const hMatch = trimmed.match(/^(#{1,6})\s+(.*)$/);
if (hMatch) {
if (currentBlock) {
blocks.push(currentBlock);
}
const level = hMatch[1].length;
const hContent = hMatch[2];
- const hType = level === 1 ? "h1" : level === 2 ? "h2" : level === 3 ? "h3" : "h4";
+ const hType = `h${level}` as "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
blocks.push({ type: hType, content: hContent });
currentBlock = null;
continue;
}
}
- // 6. Blank line
+ // 7. Blank Line
if (trimmed === "") {
if (currentBlock) {
if (
currentBlock.type === "paragraph" ||
currentBlock.type === "blockquote" ||
+ currentBlock.type === "callout" ||
currentBlock.type === "ul" ||
currentBlock.type === "ol"
) {
@@ -314,7 +559,7 @@ export function parseBlocks(content: string): Block[] {
continue;
}
- // 7. Paragraph
+ // 8. Paragraph
if (currentBlock && currentBlock.type === "paragraph") {
currentBlock.lines!.push(line);
} else {
@@ -332,41 +577,126 @@ export function parseBlocks(content: string): Block[] {
return blocks;
}
+// Image Lightbox Modal using React Portal
+function ImageLightbox({
+ src,
+ alt,
+ onClose,
+}: {
+ src: string;
+ alt: string;
+ onClose: () => void;
+}) {
+ const [mounted, setMounted] = useState(false);
+
+ useEffect(() => {
+ setMounted(true);
+ // Lock background scroll when Lightbox is open
+ const originalStyle = document.body.style.overflow;
+ document.body.style.overflow = "hidden";
+
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === "Escape") onClose();
+ };
+ window.addEventListener("keydown", handleKeyDown);
+
+ return () => {
+ document.body.style.overflow = originalStyle;
+ window.removeEventListener("keydown", handleKeyDown);
+ };
+ }, [onClose]);
+
+ if (!mounted || typeof document === "undefined") return null;
+
+ return createPortal(
+
+
+
e.stopPropagation()}
+ >
+ {/* eslint-disable-next-line @next/next/no-img-element */}
+

+ {alt && (
+
+ {alt}
+
+ )}
+
+
,
+ document.body
+ );
+}
+
export default function Markdown({ content }: { content: string }) {
+ const [activeImage, setActiveImage] = useState<{ url: string; alt: string } | null>(null);
const blocks = parseBlocks(content);
+ const handleImageClick = (url: string, alt: string) => {
+ setActiveImage({ url, alt });
+ };
+
return (
-
+
{blocks.map((block, idx) => {
const key = `${block.type}-${idx}`;
switch (block.type) {
+ case "hr":
+ return (
+
+ );
+
case "table": {
const data = block.tableData;
if (!data) return null;
return (
-
-
+
+
-
+
{data.headers.map((header, i) => {
const align = data.aligns[i] || "left";
return (
|
- {parseInline(header)}
+ {parseInline(header, handleImageClick)}
|
);
})}
-
+
{data.rows.map((row, rIdx) => (
{row.map((cell, cIdx) => {
const align = data.aligns[cIdx] || "left";
@@ -374,9 +704,9 @@ export default function Markdown({ content }: { content: string }) {
|
- {parseInline(cell)}
+ {parseInline(cell, handleImageClick)}
|
);
})}
@@ -387,95 +717,171 @@ export default function Markdown({ content }: { content: string }) {
);
}
+
case "h1":
- return (
-
- {parseInline(block.content || "")}
-
- );
case "h2":
- return (
-
- {parseInline(block.content || "")}
-
- );
case "h3":
- return (
-
- {parseInline(block.content || "")}
-
- );
case "h4":
+ case "h5":
+ case "h6": {
+ const textContent = block.content || "";
+ const slug = textContent
+ .toLowerCase()
+ .replace(/[^\w\u4e00-\u9fa5]+/g, "-")
+ .replace(/^-+|-+$/g, "");
+ const headingId = slug || `heading-${idx}`;
+
+ const baseHeadingClasses =
+ "group relative font-serif text-(--fg-color) tracking-wide leading-snug font-normal flex items-center gap-2.5";
+
+ if (block.type === "h1") {
+ return (
+
+
+ {parseInline(textContent, handleImageClick)}
+
+
+
+
+ );
+ }
+ if (block.type === "h2") {
+ return (
+
+
+ {parseInline(textContent, handleImageClick)}
+
+
+
+
+ );
+ }
+ if (block.type === "h3") {
+ return (
+
+
+ {parseInline(textContent, handleImageClick)}
+
+
+
+
+ );
+ }
return (
- {parseInline(block.content || "")}
+ {parseInline(textContent, handleImageClick)}
);
+ }
+
+ case "callout": {
+ const calloutType = block.calloutType || "NOTE";
+ const config = CALLOUT_MAP[calloutType];
+ const Icon = config.icon;
+ const calloutText = block.lines ? block.lines.join(" ") : "";
+
+ return (
+
+
+
+ {config.title}
+
+
+ {parseInline(calloutText, handleImageClick)}
+
+
+ );
+ }
+
+ case "blockquote": {
+ const quoteText = block.lines ? block.lines.join(" ") : "";
+ return (
+
+ {parseInline(quoteText, handleImageClick)}
+
+ );
+ }
+
case "paragraph": {
const text = block.lines ? block.lines.join(" ") : "";
return (
- {parseInline(text)}
+ {parseInline(text, handleImageClick)}
);
}
- case "blockquote": {
- const text = block.lines ? block.lines.join(" ") : "";
- return (
-
- {parseInline(text)}
-
- );
- }
+
case "ul":
return (
- {block.lines?.map((line, i) => (
- -
-
- {parseInline(line)}
-
- ))}
+ {block.lines?.map((line, i) => {
+ const isTask = /^\[([ xX])\]/.test(line.trim());
+ return (
+ -
+ {!isTask && (
+
+ )}
+ {parseInline(line, handleImageClick)}
+
+ );
+ })}
);
+
case "ol":
return (
{block.lines?.map((line, i) => (
-
- {parseInline(line)}
+ {parseInline(line, handleImageClick)}
))}
);
+
case "code": {
const codeText = block.lines ? block.lines.join("\n") : "";
const lang = block.lang;
@@ -493,29 +899,42 @@ export default function Markdown({ content }: { content: string }) {
return (
- {/* Mac 风格三色窗口控制栏 */}
-
+ {/* Mac Terminal Topbar */}
+
-
- {block.lang || "code"}
-
+
+
+ {block.lang || "code"}
+
+
+
-
+
);
}
+
default:
return null;
}
})}
+
+ {/* Lightbox Modal */}
+ {activeImage && (
+
setActiveImage(null)}
+ />
+ )}
);
}
diff --git a/src/components/ui/TapeStation.tsx b/src/components/ui/TapeStation.tsx
index d21e01d..1f7b0b9 100644
--- a/src/components/ui/TapeStation.tsx
+++ b/src/components/ui/TapeStation.tsx
@@ -1,6 +1,4 @@
"use client";
-/* eslint-disable react-hooks/set-state-in-effect */
-/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useState, useEffect, useRef } from "react";
diff --git a/src/data/writing.ts b/src/data/writing.ts
index 5693cdc..108cf2f 100644
--- a/src/data/writing.ts
+++ b/src/data/writing.ts
@@ -144,40 +144,81 @@ export const writingData: Post[] = [
visibility: "public",
cover: "/assets/writing-camera.png",
description: "这是一篇专门用来测试自定义 Markdown 渲染引擎排版与样式的测试文章。涵盖了标题、列表、引用、代码块以及行内标记等元素。",
- content: `# 自定义 Markdown 引擎测试
+ content: `# Markdown 渲染引擎测试与排版全集
-这是一个段落,包含 **粗体字**,*斜体字*,以及一个 [指向 GitHub](https://github.com) 的超链接。同时也可以包含 \`const test = "inline code"\` 这样的行内代码标记。
+这是一篇专门用来验证 Markdown 渲染引擎排版、调色与交互体验的测试文章。文章包含了行内样式 **粗体字**、*斜体字*、~~删除线~~、==文本高亮==、按键提示 Cmd + K 以及 [个人档案馆](https://github.com) 外部链接。
-这里测试一个无序列表:
-- 这是一个包含 **加粗文本** 的列表项
-- 这是第二个列表项,包含一个 [链接](https://google.com)
-- 这是一个简单的列表项
+---
-接下来是一个有序列表:
-1. 第一项:初始化个人生活档案馆
-2. 第二项:编写零依赖 Markdown 解析器
-3. 第三项:验证样式与系统性能
+## 一、Alert 与 Callout 提示卡片测试
-> 这里是一个引用块测试。
-> 胶片的温度在于银盐的颗粒感,而数字文字的温度,则在于那些被记录下来的微小日常。—— 生活档案馆
+> [!NOTE]
+> 这是一个 **NOTE** 提示块。常用于提供背景补充信息或相关说明。
-下面是代码块测试:
+> [!TIP]
+> 这是一个 **TIP** 技巧提示块。可以放置提高效率的小技巧或最佳实践。
+
+> [!IMPORTANT]
+> 这是一个 **IMPORTANT** 重要提示块。包含关键流程或容易遗漏的要点。
+
+> [!WARNING]
+> 这是一个 **WARNING** 警告提示块。提醒使用者注意可能的副作用或注意事项。
+
+> [!CAUTION]
+> 这是一个 **CAUTION** 危险/严禁提示块。高风险操作请务必仔细确认!
+
+---
+
+## 二、普通引用与任务列表
+
+> 胶片的温度在于银盐的颗粒感,而数字文字的温度,则在于那些被记录下来的微小日常。
+> —— *生活档案馆·Rrtiamo*
+
+这里是系统运维与架构任务清单:
+
+- [x] 重构 Markdown 渲染引擎,完美适配主题色
+- [x] 支持各种 Callout 警示框与图片 Lightbox 模态框
+- [x] 优化代码终端顶栏与一键复制功能
+- [ ] 增加更多图文混排视觉组件
+
+---
+
+## 三、数据表格展示
+
+| 功能特性 | 解析支持 | 样式匹配 | 交互扩展 |
+| :--- | :---: | :---: | ---: |
+| 标题与锚点 | 支持 H1-H6 | 暖色饰条点缀 | 悬停锚点图标 |
+| 提示框 (Callouts) | NOTE/TIP/WARNING等 | 5色主题适调 | 专属 Lucide 图标 |
+| 代码终端 | 高亮 (hljs) | Mac 三色卡片 | 一键复制代码 |
+| 高清大图 | 胶片外框说明 | 悬停遮罩 hover | 弹出 Lightbox 预览 |
+
+---
+
+## 四、代码终端与复制功能
\`\`\`typescript
interface Post {
slug: string;
title: string;
+ category: string;
content: string;
}
-const renderMarkdown = (post: Post) => {
- console.log("Rendering post:", post.title);
- return \`Rendering \${post.slug}...\`;
-};
+// 渲染流程示例函数
+export function renderPost(post: Post): string {
+ console.log(\`Rendering post: \${post.title}\`);
+ return \`\${post.content}\`;
+}
\`\`\`
-## 小结
+---
-如果所有区块如标题、列表、引用和代码块都排版美观、字体易读、且代码块显示为精致的深色终端样式,则说明渲染引擎表现符合预期。`
+## 五、胶片影像与 Lightbox 放大
+
+
+
+## 六、小结
+
+如果标题左侧带有暖色饰条、警示框色彩柔和且带有对应图标、代码块能够一键复制、图片点击可以弹出半透明全屏大图预览,则说明渲染引擎升级圆满完成!`
}
];
diff --git a/src/hooks/useArticles.ts b/src/hooks/useArticles.ts
index 6cad320..8770d2c 100644
--- a/src/hooks/useArticles.ts
+++ b/src/hooks/useArticles.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
import { useState, useEffect } from "react";
import { Post, writingData } from "@/data/writing";
import { getBlogsList } from "@/api/blogs";
diff --git a/src/hooks/useGallery.ts b/src/hooks/useGallery.ts
index 1d5ca7d..c1b642a 100644
--- a/src/hooks/useGallery.ts
+++ b/src/hooks/useGallery.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
import { useState, useEffect } from "react";
import { GalleryPhoto, galleryData } from "@/data/gallery";
import { getGalleryList } from "@/api/gallery";
diff --git a/src/hooks/useSysConfig.ts b/src/hooks/useSysConfig.ts
index f2dd9d6..8d6a54d 100644
--- a/src/hooks/useSysConfig.ts
+++ b/src/hooks/useSysConfig.ts
@@ -1,4 +1,5 @@
import { useState, useEffect } from "react";
+import { getPublicConfig } from "@/api/config";
export interface SysConfig {
configKey: string;
@@ -10,11 +11,8 @@ export function useSysConfig() {
const [loading, setLoading] = useState(true);
useEffect(() => {
- fetch("http://localhost:8080/api/config/public")
- .then((res) => {
- if (!res.ok) throw new Error("HTTP status " + res.status);
- return res.json();
- })
+ getPublicConfig()
+ .then((res) => res.data)
.then((data) => {
if (data.code === 200) {
setConfigs(data.data || []);