react-blog-boilerplate
v1.0.0
Published
A modern, customizable React blog with Markdown support
Maintainers
Readme
React Blog Boilerplate
A modern, customizable React blog with Markdown support, built with Vite, React, TypeScript, and Tailwind CSS.
Features
- Markdown Blog: Write your blog posts in Markdown with frontmatter support
- Search Functionality: Built-in search for blog posts
- SEO Optimized: Meta tags, canonical URLs, and auto-generated sitemap
- Responsive Design: Looks great on all devices with Tailwind CSS
- Fast Performance: Built with Vite for optimal development and production performance
- Image Handling: Automatic featured image extraction from blog posts
- YouTube Embed Support: Easily embed YouTube videos in your blog posts
- Zip File Support: Upload multiple blog posts at once via zip files
Installation
npm install react-blog-boilerplate
# or
yarn add react-blog-boilerplateUsage
Basic Usage
import { BlogList, BlogPost, BlogPreview } from 'react-blog-boilerplate';
import 'react-blog-boilerplate/style.css'; // Import styles
// Use in your React Router setup
function App() {
return (
<Router>
<Routes>
<Route path="/blog" element={<BlogList />} />
<Route path="/blog/:slug" element={<BlogPost />} />
<Route path="/" element={
<div>
<h1>Welcome to my blog</h1>
<BlogPreview />
</div>
} />
</Routes>
</Router>
);
}Available Components
The library exports the following components:
BlogList: Displays a paginated list of all blog postsBlogPost: Displays a single blog postBlogPreview: Shows a preview of the most recent blog postsSearchBar: Provides search functionality for blog postsShareButtons: Social media sharing buttons for blog postsSitemap: Generates a site map pagePagination: Reusable pagination componentCTABlock: Call-to-action block for sidebar or footerRelatedBlogPosts: Shows related blog postsScrollToTop: Utility component that scrolls to top on navigation
Utilities
createSlug: Generate URL-friendly slugs from textextractFirstImage: Extract the first image from a blog postgetDefaultFeaturedImage: Get a default image when no featured image is available
Types
BlogPost: TypeScript interface for blog post structureSitemapUrl: TypeScript interface for sitemap URLs
Blog Content Structure
Blog content can be added in two ways:
- Individual markdown files in the
blog-contentdirectory - Zip files containing markdown files in the
blog-zipsdirectory
When you run npm run build, the system will:
- Extract any zip files from
blog-zipsinto theblog-contentdirectory - Include all markdown files in the build
Creating Blog Posts
Create a new Markdown file in the blog-content directory. Your blog post should include frontmatter at the beginning:
---
title: Your Blog Post Title
date: 2025-04-01
author: Your Name
excerpt: A brief summary of the blog post that will appear in listings
---
# Your Blog Post Title
Your content goes here...Customization
Site Configuration
Configure your site by creating a site config file:
// src/config/mySiteConfig.js
import { siteConfig as defaultConfig } from 'react-blog-boilerplate';
const mySiteConfig = {
...defaultConfig,
title: "Your Site Name",
description: "Your site description",
defaultAuthor: "Default Author Name",
domain: "yoursitename.com",
};
export default mySiteConfig;License
This project is MIT licensed.
