About Slate Blog

Jan 21 ·
1 分钟阅读

✨ Features

🪜 Framework

🔨 Usage

Terminal window
# Start local server
npm run dev
# or
yarn dev
# or
pnpm dev
# Build
npm run build
# or
yarn build
# or
pnpm build

🗂 Directory Structure

- plugins/ # Custom plugins
- src/
├── assets/ # Asset files
├── components/ # Components
├── content/ # Content collections
├── helpers/ # Business logic
├── pages/ # Pages
└── typings/ # Common types

Articles are stored in the src/content/post directory, supporting markdown and mdx formats. The filename is the path name. For example, src/content/post/my-first-post.md => https://your-blog.com/blog/my-first-post.

Configuration

Theme configuration is done through slate.config.ts in the root directory.

OptionDescriptionTypeDefault
siteFinal deployment linkstring-
titleWebsite titlestring-
descriptionWebsite descriptionstring-
langLanguagestringzh-CN
avatarAvatarstring-
sitemapWebsite sitemap configuration{ hostname: string }-
readTimeShow reading timebooleanfalse
lastModifiedShow last modified timebooleanfalse
algoliaDocsearch configuration{ appId: string, apiKey: string, indexName: string }-
followFollow subscription authentication configuration{ feedId: string, userId: string }-
footerWebsite footer configuration{ copyright: string }-

Algolia Application

  1. Deploy your site first
  2. Apply for an apiKey at algolia
  3. After successful application, configure algolia in slate.config.ts
  4. Redeploy

Follow Subscription Authentication

  1. Register a follow account
  2. Deploy your site
  3. Click the + button on follow, select RSS subscription, and enter the rss link (usually [site]/rss.xml, where site is the value of site in slate.config.ts)
  4. Redeploy

Article Frontmatter Description

OptionDescriptionTypeRequired
titleArticle titlestringYes
descriptionArticle descriptionstringNo
tagsArticle tagsstring[]No
draftWhether it’s a draft. When not provided or false, pubDate must be provided; drafts are only visible in local previewbooleanNo
pubDateArticle publication datedateNo, required when draft is false

For more details, check the src/content/config.ts file

Example

---
title: 40 questions
description: This repo maintains revisons and translations to the list of 40 questions I ask myself each year and each decade.
tags:
- Life
- Thinking
- Writing
pubDate: 2025-01-06
---
编辑于 Jan 21
© 2025 Slate Blog