Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default async function PostPage({ params }: PostPageProps) {
<div className="mx-auto w-full max-w-[56rem] 2xl:max-w-[60rem] xl:max-w-none">
<div
data-article-body
className="prose prose-lg prose-neutral max-w-none dark:prose-invert prose-p:leading-relaxed prose-p:text-neutral-700 dark:prose-p:text-neutral-300 prose-headings:font-bold prose-headings:tracking-tight prose-h2:mt-10 prose-h2:mb-4 prose-h3:mt-8 prose-h3:mb-3 prose-a:text-green-600 prose-a:no-underline hover:prose-a:underline dark:prose-a:text-green-400 prose-li:my-1 prose-ul:my-4 prose-ol:my-4 prose-code:rounded-sm prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-px prose-code:text-[0.9em] prose-code:text-green-700 prose-code:before:content-none prose-code:after:content-none dark:prose-code:bg-neutral-800 dark:prose-code:text-green-400 prose-pre:p-0 prose-pre:bg-transparent prose-pre:border-0 prose-table:my-6 prose-th:bg-neutral-100 dark:prose-th:bg-neutral-800 prose-blockquote:border-l-green-500 dark:prose-blockquote:border-l-green-500 prose-blockquote:bg-emerald-50 dark:prose-blockquote:bg-neutral-900/50 prose-blockquote:py-1 prose-blockquote:px-4 prose-blockquote:rounded-r-lg prose-hr:my-8"
className="prose prose-lg prose-neutral max-w-none dark:prose-invert prose-p:leading-relaxed prose-p:text-neutral-700 dark:prose-p:text-neutral-300 prose-headings:font-bold prose-headings:tracking-tight prose-h2:mt-10 prose-h2:mb-4 prose-h3:mt-8 prose-h3:mb-3 prose-a:text-green-600 prose-a:no-underline hover:prose-a:underline dark:prose-a:text-green-400 prose-li:my-1 prose-ul:my-4 prose-ol:my-4 prose-code:rounded-md prose-code:bg-neutral-100 prose-code:px-[0.4em] prose-code:py-[0.2em] prose-code:text-[0.85em] prose-code:font-normal prose-code:text-neutral-800 prose-code:before:content-none prose-code:after:content-none dark:prose-code:bg-neutral-800/90 dark:prose-code:text-neutral-200 prose-pre:p-0 prose-pre:bg-transparent prose-pre:border-0 prose-table:my-6 prose-th:bg-neutral-100 dark:prose-th:bg-neutral-800 prose-blockquote:border-l-green-500 dark:prose-blockquote:border-l-green-500 prose-blockquote:bg-emerald-50 dark:prose-blockquote:bg-neutral-900/50 prose-blockquote:py-1 prose-blockquote:px-4 prose-blockquote:rounded-r-lg prose-hr:my-8"
>
<MDXContent code={post.content} />
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
padding: 0;
}

/* Inline code in GFM-style tables should stay on one line and let the table scroll horizontally. */
.prose :where(th, td) code {
white-space: nowrap;
}

/* GitHub Alerts (remark-alerts) */
.prose .markdown-alert {
position: relative;
Expand Down
4 changes: 2 additions & 2 deletions app/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ const PROJECTS: Project[] = [
},
{
id: "6",
title: "MT-AutoOptimize",
title: "MT-Agent",
preview: "Coding Agent for MT-3000",
description: "LangGraph搭建ReAct循环,仿照Gemini-CLI的Coding Agent",
techStack: "LangGraph, Python, REPL",
image: "/images/projects/project6.png",
href: "https://github.com/Iamnotphage/MT-AutoOptimize",
href: "https://github.com/Iamnotphage/MT-Agent",
}
];

Expand Down
2 changes: 1 addition & 1 deletion components/mdx-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function H4({ children, ...props }: ComponentProps<'h4'>) {

// Inline code(code block 内的 code 由 data-language 区分,不做内联样式)
const inlineCodeClass =
'rounded-sm border border-neutral-300/90 bg-neutral-100 px-1 py-px font-mono text-[0.9em] text-neutral-800 dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-200 break-all'
'rounded-md bg-neutral-100 px-[0.4em] py-[0.2em] font-mono text-[0.85em] text-neutral-800 whitespace-break-spaces dark:bg-neutral-800/90 dark:text-neutral-200'

function Code({
children,
Expand Down
44 changes: 43 additions & 1 deletion velite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,48 @@ import { visit } from 'unist-util-visit'
import type { Root } from 'hast'
import type { Root as MdastRoot } from 'mdast'

/** 兼容单行三反引号:```foo``` -> 代码块(默认 text),避免被 mdast 解析成 inlineCode */
function remarkSingleLineFencedCode() {
return (tree: MdastRoot, file?: { value?: unknown }) => {
const source = typeof file?.value === 'string' ? file.value : ''
if (!source) return

visit(tree, 'paragraph', (node, index, parent) => {
if (node.children.length !== 1) return

const only = node.children[0]
if (only.type !== 'inlineCode' || !node.position) return
if (typeof index !== 'number' || !parent || !('children' in parent) || !Array.isArray(parent.children)) return

const startOffset = node.position.start.offset
const endOffset = node.position.end.offset
if (typeof startOffset !== 'number' || typeof endOffset !== 'number') return

const raw = source.slice(startOffset, endOffset).trim()
if (!/^```[^`\r\n]+```$/.test(raw)) return

parent.children[index] = {
type: 'code',
lang: 'text',
meta: null,
value: only.value,
position: node.position,
}
})
}
}

/** 未显式声明语言的 fenced code block 默认按 text 处理 */
function remarkDefaultCodeLanguage() {
return (tree: MdastRoot) => {
visit(tree, 'code', (node) => {
if (!node.lang || !node.lang.trim()) {
node.lang = 'text'
}
})
}
}

/** 两个及以上连续空行时插入可见间距:在 mdast 中插入一个会渲染为 div 的占位节点 */
function remarkDoubleBlankSpacer() {
return (tree: MdastRoot) => {
Expand Down Expand Up @@ -189,6 +231,6 @@ export default defineConfig({
},
],
],
remarkPlugins: [remarkGfm, remarkGitHubAlerts, remarkMath, remarkGemoji, remarkDoubleBlankSpacer],
remarkPlugins: [remarkGfm, remarkSingleLineFencedCode, remarkDefaultCodeLanguage, remarkGitHubAlerts, remarkMath, remarkGemoji, remarkDoubleBlankSpacer],
},
})
Loading