markdown-history
v0.1.0
Published
Generic markdown rendering, wiki-style link rewriting, and Git-based unified/split diff components for React projects.
Maintainers
Readme
markdown-history
Generic markdown rendering + wiki-style linking + Git-based diff views for React projects.
- Render markdown with anchors and automatic links:
- Rewrites relative
.md/.mdxand[[WikiLinks]](including#Section) to your app routes
- Rewrites relative
- Show Git diffs with GitHub-like unified and split views
- Lightweight utilities to read Git history/diffs server-side
Install
pnpm add markdown-historyUsage (Next.js)
1) Render markdown with link rewriting
import { renderMarkdownWithLinks } from 'markdown-history';
const html = await renderMarkdownWithLinks(mdString, pagesIndex, path.dirname(sourcePath));pagesIndex: Array of{ sourcePath: string; title: string; route: string }- The plugin will rewrite
[Link](../Some Page.md#Anchor)and[[Some Page#Anchor]]to/some-page#anchor
2) Diff views (client)
'use client'
import { UnifiedDiff, SplitDiff } from 'markdown-history';
export default function Diff({ diff }: { diff: string }) {
return <UnifiedDiff diff={diff} />
}3) Git utilities (server)
import { gitHistory, gitDiff, findGitRoot } from 'markdown-history';
const root = findGitRoot(process.cwd());
const relPath = 'docs/page.md';
const commits = gitHistory(relPath, 30);
const diff = gitDiff(relPath, commits[1].sha, commits[0].sha, { ignoreWhitespace: true });Build
pnpm -C packages/blueprints-core buildNotes
- No WIN-specific logic; bring your own index of pages and routes
- Git commands execute in the nearest
.gitroot (or passcwdif needed) - Unified/Split components expect CSS classes used in examples (diff-table/grid); adapt to your design
License
MIT (add your preferred license if publishing)
