Skip to content

Commit c20a6be

Browse files
committed
docs: write explainer documentation
1 parent 473abd4 commit c20a6be

53 files changed

Lines changed: 2537 additions & 852 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/src/content/docs/another-lib/_meta.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/docs/src/content/docs/another-lib/v1/en/getting-started.mdx

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/docs/src/content/docs/another-lib/v2/en/getting-started.mdx

Lines changed: 0 additions & 33 deletions
This file was deleted.

apps/docs/src/content/docs/another-lib/v2/en/guides/_meta.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/docs/src/content/docs/another-lib/v2/en/guides/migration.mdx

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"icon": "book-open",
3+
"title": "Explainer"
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"title": "Blog",
3+
"icon": "newspaper",
4+
"order": 7
5+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Overview
3+
description: Learn about the Explainer blog app, its content structure, and features.
4+
icon: newspaper
5+
order: 1
6+
---
7+
8+
# Blog
9+
10+
The blog is a standalone Astro app at `apps/blog/` running on port **4322**. It supports posts with tags, authors, cover images, drafts, and an RSS feed.
11+
12+
## Content location
13+
14+
Blog posts are MDX files in:
15+
16+
```text
17+
apps/blog/src/content/posts/*.mdx
18+
```
19+
20+
## Frontmatter schema
21+
22+
```mdx [my-post.mdx]
23+
---
24+
title: Introducing Explainer v2
25+
description: A new documentation boilerplate built with Astro, React, and Tailwind CSS 4.
26+
date: 2026-03-10
27+
tags: [announcement, release]
28+
cover: /images/cover.png
29+
draft: false
30+
author: leadcode_dev
31+
---
32+
```
33+
34+
| Field | Type | Required | Description |
35+
|-------|------|----------|-------------|
36+
| `title` | `string` | Yes | Post title |
37+
| `description` | `string` | Yes | Short description for cards and SEO |
38+
| `date` | `date` | Yes | Publication date (future dates are hidden) |
39+
| `tags` | `string[]` | No | Tags for filtering (default: `[]`) |
40+
| `cover` | `string` | No | Cover image path |
41+
| `draft` | `boolean` | No | Draft posts are hidden from listing (default: `false`) |
42+
| `author` | `string` | No | Author key matching the authors map |
43+
44+
## Features
45+
46+
- **Draft mode** — Set `draft: true` to hide a post from listings while still accessible by direct URL during development
47+
- **Tag filtering** — Posts can be filtered by tag on the blog index page
48+
- **RSS feed** — An RSS feed is automatically generated at `/rss.xml`
49+
- **Reading time** — Estimated reading time is calculated at 200 words per minute
50+
- **Featured posts** — The first posts are displayed in a larger card layout on the index
51+
- **Pagination** — Posts are paginated at 10 per page
52+
53+
## Authors
54+
55+
Authors are defined in `apps/blog/src/lib/authors.ts`:
56+
57+
```typescript [authors.ts]
58+
export const authors: Record<string, Author> = {
59+
leadcode_dev: {
60+
name: 'Baptiste Parmantier',
61+
title: 'Creator of Explainer',
62+
avatar: 'https://avatars.githubusercontent.com/u/8946317?v=4',
63+
href: 'https://github.com/LeadcodeDev',
64+
},
65+
}
66+
```
67+
68+
Reference an author by their key in the post frontmatter: `author: leadcode_dev`.
69+
70+
## Development
71+
72+
```bash
73+
pnpm dev --filter @explainer/blog
74+
```
75+
76+
The blog runs on `http://localhost:4322`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"title": "Code Blocks",
3+
"icon": "code",
4+
"order": 5,
5+
"type": "group"
6+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
title: Diffs & Focus
3+
description: Show code additions, removals, focus areas, and error highlights.
4+
icon: git-compare
5+
order: 4
6+
---
7+
8+
# Diffs & Focus
9+
10+
Highlight code changes, focus areas, and errors using inline comment annotations.
11+
12+
## Diff notation
13+
14+
Mark lines as added or removed using `// [!code ++]` and `// [!code --]`:
15+
16+
````mdx
17+
```typescript
18+
function createUser(name: string) {
19+
const user = { name } // [!code --]
20+
const user = { name, id: generateId() } // [!code ++]
21+
return user
22+
}
23+
```
24+
````
25+
26+
Renders as:
27+
28+
```typescript
29+
function createUser(name: string) {
30+
const user = { name } // [!code --]
31+
const user = { name, id: generateId() } // [!code ++]
32+
return user
33+
}
34+
```
35+
36+
Removed lines are highlighted in red, added lines in green.
37+
38+
## Focus mode
39+
40+
Use `// [!code focus]` to dim all lines except the focused ones:
41+
42+
````mdx
43+
```typescript
44+
import { defineConfig } from 'astro/config'
45+
import react from '@astrojs/react'
46+
import mdx from '@astrojs/mdx'
47+
48+
export default defineConfig({
49+
integrations: [
50+
react(), // [!code focus]
51+
mdx(), // [!code focus]
52+
]
53+
})
54+
```
55+
````
56+
57+
Renders as:
58+
59+
```typescript
60+
import { defineConfig } from 'astro/config'
61+
import react from '@astrojs/react'
62+
import mdx from '@astrojs/mdx'
63+
64+
export default defineConfig({
65+
integrations: [
66+
react(), // [!code focus]
67+
mdx(), // [!code focus]
68+
]
69+
})
70+
```
71+
72+
## Error highlighting
73+
74+
Mark lines with `// [!code error]` to highlight them as errors:
75+
76+
````mdx
77+
```typescript
78+
const port = process.env.PORT
79+
app.listen(port) // [!code error]
80+
app.listen(Number(port)) // [!code highlight]
81+
```
82+
````
83+
84+
Renders as:
85+
86+
```typescript
87+
const port = process.env.PORT
88+
app.listen(port) // [!code error]
89+
app.listen(Number(port)) // [!code highlight]
90+
```
91+
92+
## Combining annotations
93+
94+
You can use multiple annotation types in the same code block:
95+
96+
```typescript
97+
function connect(url: string) {
98+
const oldClient = createClient(url) // [!code --]
99+
const newClient = createClient(url, { // [!code ++]
100+
retry: true, // [!code ++]
101+
timeout: 5000, // [!code ++]
102+
}) // [!code ++]
103+
return newClient // [!code focus]
104+
}
105+
```
106+
107+
:::callout{variant="info"}
108+
The inline comments (`// [!code ...]`) are stripped from the rendered output — readers only see the visual highlights.
109+
:::

0 commit comments

Comments
 (0)