$ cat post.md
Welcome to my blog! In this post, I'll walk you through how I built this terminal-themed blog using modern web technologies.
The blog is built with:
The interface mimics a terminal window, complete with:
walt@desktop ~ $
)Posts are stored as Markdown files and include:
The blog features:
Here's how we parse markdown files:
typescriptimport matter from 'gray-matter';
import fs from 'fs';
import path from 'path';
export function getPostData(id: string) {
const fullPath = path.join(process.cwd(), 'posts', `${id}.md`);
const fileContents = fs.readFileSync(fullPath, 'utf8');
const { data, content } = matter(fileContents);
return {
id,
content,
...data
};
}
And here's some example CSS for the terminal theme:
css.terminal-window {
background-color: #1a1b26;
border-radius: 8px;
padding: 1.5rem;
font-family: 'Fira Code', monospace;
color: #a9b1d6;
}
.command-prompt::before {
content: "$ ";
color: #7aa2f7;
}
We use several plugins to enhance our markdown:
rehype-highlight
for code syntax highlightingremark-gfm
for GitHub-flavored markdownrehype-raw
for handling HTML in markdownTo achieve the terminal look:
jsx<div className="terminal-prompt">
<span className="user">walt</span>
<span className="separator">@</span>
<span className="machine">desktop</span>
<span className="path">~/blog</span>
<span className="command">$ cat current-post.md</span>
</div>
Images are supported with terminal-style frames:
And videos can be embedded: