更新文档

This commit is contained in:
Kerry
2025-03-10 03:11:48 +08:00
parent 07576f3626
commit dd976fe05d
19 changed files with 4002 additions and 9 deletions

14
docs/.gitignore vendored Normal file
View File

@@ -0,0 +1,14 @@
# Local
.DS_Store
*.local
*.log*
# Dist
node_modules
dist/
doc_build/
# IDE
.vscode/*
!.vscode/extensions.json
.idea

29
docs/README.md Normal file
View File

@@ -0,0 +1,29 @@
# Rspress website
## Setup
Install the dependencies:
```bash
npm install
```
## Get started
Start the dev server:
```bash
npm run dev
```
Build the website for production:
```bash
npm run build
```
Preview the production build locally:
```bash
npm run preview
```

16
docs/docs/_meta.json Normal file
View File

@@ -0,0 +1,16 @@
[
{
"text": "Guide",
"link": "/guide/",
"activeMatch": "/guide/"
},
{
"text": "Hello world",
"link": "/hello/",
"activeMatch": "/hello/"
},
{
"text": "API",
"link": "https://rspress.dev/api/index.html"
}
]

View File

@@ -0,0 +1 @@
["index"]

210
docs/docs/guide/index.md Normal file
View File

@@ -0,0 +1,210 @@
# Markdown & MDX
Rspress supports not only Markdown but also [MDX](https://mdxjs.com/), a powerful way to develop content.
## Markdown
MDX is a superset of Markdown, which means you can write Markdown files as usual. For example:
```md
# Hello world
```
## Use component
When you want to use React components in Markdown files, you should name your files with `.mdx` extension. For example:
```mdx
// docs/index.mdx
import { CustomComponent } from './custom';
# Hello world
<CustomComponent />
```
## Front matter
You can add Front Matter at the beginning of your Markdown file, which is a YAML-formatted object that defines some metadata. For example:
```yaml
---
title: Hello world
---
```
> Note: By default, Rspress uses h1 headings as html headings.
You can also access properties defined in Front Matter in the body, for example:
```markdown
---
title: Hello world
---
# {frontmatter.title}
```
The previously defined properties will be passed to the component as `frontmatter` properties. So the final output will be:
```html
<h1>Hello world</h1>
```
## Custom container
You can use the `:::` syntax to create custom containers and support custom titles. For example:
**Input:**
```markdown
:::tip
This is a `block` of type `tip`
:::
:::info
This is a `block` of type `info`
:::
:::warning
This is a `block` of type `warning`
:::
:::danger
This is a `block` of type `danger`
:::
::: details
This is a `block` of type `details`
:::
:::tip Custom Title
This is a `block` of `Custom Title`
:::
:::tip{title="Custom Title"}
This is a `block` of `Custom Title`
:::
```
**Output:**
:::tip
This is a `block` of type `tip`
:::
:::info
This is a `block` of type `info`
:::
:::warning
This is a `block` of type `warning`
:::
:::danger
This is a `block` of type `danger`
:::
::: details
This is a `block` of type `details`
:::
:::tip Custom Title
This is a `block` of `Custom Title`
:::
:::tip{title="Custom Title"}
This is a `block` of `Custom Title`
:::
## Code block
### Basic usage
You can use the \`\`\` syntax to create code blocks and support custom titles. For example:
**Input:**
````md
```js
console.log('Hello World');
```
```js title="hello.js"
console.log('Hello World');
```
````
**Output:**
```js
console.log('Hello World');
```
```js title="hello.js"
console.log('Hello World');
```
### Show line numbers
If you want to display line numbers, you can enable the `showLineNumbers` option in the config file:
```ts title="rspress.config.ts"
export default {
// ...
markdown: {
showLineNumbers: true,
},
};
```
### Wrap code
If you want to wrap long code line by default, you can enable the `defaultWrapCode` option in the config file:
```ts title="rspress.config.ts"
export default {
// ...
markdown: {
defaultWrapCode: true,
},
};
```
### Line highlighting
You can also apply line highlighting and code block title at the same time, for example:
**Input:**
````md
```js title="hello.js" {1,3-5}
console.log('Hello World');
const a = 1;
console.log(a);
const b = 2;
console.log(b);
```
````
**Output:**
```js title="hello.js" {1,3-5}
console.log('Hello World');
const a = 1;
console.log(a);
const b = 2;
console.log(b);
```
## Rustify MDX compiler
You can enable Rustify MDX compiler by following config:

5
docs/docs/hello.md Normal file
View File

@@ -0,0 +1,5 @@
# Hello world!
## Start
Write something to build your own docs! 🎁

37
docs/docs/index.md Normal file
View File

@@ -0,0 +1,37 @@
---
pageType: home
hero:
name: My Site
text: A cool website!
tagline: This is the tagline
actions:
- theme: brand
text: Quick Start
link: /guide/
- theme: alt
text: GitHub
link: https://github.com/web-infra-dev/rspress
image:
src: /icon-min.png
alt: Logo
features:
- title: Blazing fast build speed
details: The core compilation module is based on the Rust front-end toolchain, providing a more ultimate development experience.
icon: 🏃🏻‍♀️
- title: Support for MDX content writing
details: MDX is a powerful way to write content, allowing you to use React components in Markdown.
icon: 📦
- title: Built-in full-text search
details: Automatically generates a full-text search index for you during construction, providing out-of-the-box full-text search capabilities.
icon: 🎨
- title: Simpler I18n solution
details: With the built-in I18n solution, you can easily provide multi-language support for documents or components.
icon: 🌍
- title: Static site generation
details: In production, it automatically builds into static HTML files, which can be easily deployed anywhere.
icon: 🌈
- title: Providing multiple custom capabilities
details: Through its extension mechanism, you can easily extend theme UI and build process.
icon: 🔥
---

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

16
docs/package.json Normal file
View File

@@ -0,0 +1,16 @@
{
"name": "docs",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "rspress build",
"dev": "rspress dev",
"preview": "rspress preview"
},
"dependencies": {
"rspress": "^1.40.2"
},
"devDependencies": {
"@types/node": "^18.11.17"
}
}

3622
docs/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

21
docs/rspress.config.ts Normal file
View File

@@ -0,0 +1,21 @@
import * as path from 'node:path';
import { defineConfig } from 'rspress/config';
export default defineConfig({
root: path.join(__dirname, 'docs'),
title: 'MTranServer',
icon: '/icon-min.png',
logo: {
light: '/icon-min.png',
dark: '/icon-min.png',
},
themeConfig: {
socialLinks: [
{
icon: 'github',
mode: 'link',
content: 'https://github.com/xxnuo/MTranServer',
},
],
},
});

20
docs/tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["DOM", "ES2020"],
"module": "ESNext",
"jsx": "react-jsx",
"noEmit": true,
"strict": true,
"skipLibCheck": true,
"isolatedModules": true,
"resolveJsonModule": true,
"moduleResolution": "bundler",
"useDefineForClassFields": true,
"allowImportingTsExtensions": true
},
"include": ["docs", "theme", "rspress.config.ts"],
"mdx": {
"checkMdx": true
}
}