A minimalist blog built with React and Vite, featuring support for Markdown, LaTeX equations, and code snippets.
Blog posts are stored as JavaScript files in the src/posts directory. Each post should export:
title: The post titledate: Publication dateslug: Unique identifier for the post URLcontent: The post content in Markdown format
-
Inline Code
Use single backticks for inline code: `console.log("Hello")`
-
Code Blocks
Use triple backticks with optional language name: ```javascript function hello() { console.log("Hello, world!"); } ```
-
Inline Math
Use backticks with dollar signs for inline equations: \`$E = mc^2$\`
-
Block Math
Use math code blocks for displayed equations: ```math \sum_{i=1}^n i = \frac{n(n+1)}{2} ```
- Headers: Use
#for different levels - Lists: Use
-or*for bullet points - Blockquotes: Use
>for quotes - Links: Use
[text](url)format - Bold: Use
**text** - Italic: Use
*text*
export const title = "My Blog Post";
export const date = "2024-03-19";
export const slug = "my-blog-post";
export const content = `
# My Blog Post
Here's some inline code: \`console.log("Hello")\`
Here's a code block:
\`\`\`javascript
function greet(name) {
return \`Hello, \${name}!\`;
}
\`\`\`
Here's an inline equation: \`$E = mc^2$\`
Here's a block equation:
\`\`\`math
\\sum_{i=1}^n i = \\frac{n(n+1)}{2}
\`\`\`
`;-
Install dependencies:
npm install
-
Start development server:
npm run dev
-
Build for production:
npm run build
The blog uses CSS variables for theming:
--background-color: Main background--text-body-color1: Primary text color--text-body-color2: Secondary text color--text-title-color1: Primary title color--text-title-color2: Secondary title color
Styles for different elements are defined in:
src/App.css: Global styles and theme variablessrc/components/BlogPost.css: Post-specific stylessrc/Home.css: Homepage styles
The blog is configured for deployment on GitHub Pages. Push changes to the main branch to trigger automatic deployment.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
To run the project locally:
npm install
npm run dev-
Create or Edit a Post
- Add a new
.jsfile insrc/posts/for a new post, or edit an existing one. - Use this template:
export const metadata = { title: "Your Post Title", slug: "your-post-slug" }; export const content = ` # Your Post Title Your content here in Markdown! `;
- Only
titleandslugare required inmetadata. Dates are handled automatically.
- Add a new
-
Commit Your Changes
- Use Git to commit your new or updated post:
git add src/posts/your-post.js git commit -m "Add/update blog post: Your Post Title"
- Use Git to commit your new or updated post:
-
Update Post Dates
- Run the following command to update creation and update dates for all posts based on Git history:
npm run update-git-history
- This generates/updates
src/data/git-history.json, which the site uses to display post dates.
- Run the following command to update creation and update dates for all posts based on Git history:
-
Start or Restart the Dev Server
- If your dev server is running, restart it to pick up changes in the JSON file.
-
Dates Not Updating?
- Make sure you committed your changes to Git before running
npm run update-git-history. - If you add a new post but don't see dates, check that the file is tracked by Git and committed.
- Make sure you committed your changes to Git before running
-
Error:
git-history.jsonNot Found- Run
npm run update-git-historyto generate the file. - Make sure the
src/data/directory exists.
- Run
-
Error: Node.js/child_process in Browser
- All Git operations are handled by the script, not in the browser. If you see this error, make sure you're not trying to use Node.js modules in your React code.
-
General Steps Not Working?
- Double-check that you're using Node.js v16+ and have Git installed.
- If you change the structure of your posts, update the script and utilities accordingly.
- Add or update a post: Edit files in
src/posts/ - Update post dates:
npm run update-git-history - See your changes: Restart the dev server if needed
If you are developing a production application, we recommend using TypeScript and enable type-aware lint rules. Check out the TS template to integrate TypeScript and typescript-eslint in your project.