Skip to content

Commit 6e1579d

Browse files
committed
feat(docs): show icon and version in navbar
1 parent 890f6e4 commit 6e1579d

File tree

8 files changed

+41
-10
lines changed

8 files changed

+41
-10
lines changed

saltify-docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ out/
55

66
# Dependencies
77
node_modules/
8+
9+
# Auto-generated version file
10+
app/version.ts

saltify-docs/app/[[...mdxPath]]/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { generateStaticParamsFor, importPage } from 'nextra/pages';
22
import { useMDXComponents as getMDXComponents } from '../../mdx-components';
33
import { Metadata } from 'next';
44

5-
export const generateStaticParams = generateStaticParamsFor('mdxPath');
5+
export const generateStaticParams = async () => {
6+
return generateStaticParamsFor('mdxPath')();
7+
};
68

79
type Props = {
810
params: Promise<{ slug: string; mdxPath: string[] }>;

saltify-docs/app/layout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import 'nextra-theme-docs/style.css';
44
import './styles.css';
55
import { Head, Search } from 'nextra/components';
66
import { Metadata } from 'next';
7+
import React from "react";
8+
import Image from 'next/image';
9+
import { SALTIFY_VERSION } from './version';
710

811
export const metadata: Metadata = {
912
title: 'Saltify 文档',
@@ -19,8 +22,15 @@ export default async function RootLayout({ children }: { children: React.ReactNo
1922
navbar={
2023
<Navbar
2124
logo={
22-
<div style={{ fontSize: '1.15rem' }}>
23-
<b>Saltify</b> 文档
25+
<div style={{ display: 'flex', alignItems: 'center' }}>
26+
<Image src="/saltify-150.png" alt="Saltify Logo" width={40} height={40} style={{ borderRadius: '8px' }} />
27+
<div style={{ marginLeft: '0.75rem' }} />
28+
<div style={{ fontSize: '1.15rem' }}>
29+
<b>Saltify</b> Docs
30+
<div style={{ fontSize: '0.75rem' }}>
31+
<code>v{SALTIFY_VERSION}</code>
32+
</div>
33+
</div>
2434
</div>
2535
}
2636
projectLink={'https://github.com/SaltifyDev/saltify'}

saltify-docs/app/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ code, kbd, samp, pre {
44

55
code.nextra-code {
66
font-size: 1em;
7-
}
7+
}

saltify-docs/content/docs-core/application.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
val client = SaltifyApplication {
99
connection {
1010
baseUrl = "http://localhost:3000"
11-
accessToken = "your_token" // 选填:访问令牌(不用加 Bearer)
11+
accessToken = "your_token" // 访问令牌
1212

1313
// 事件服务连接配置
1414
events {
1515
type = EventConnectionType.WebSocket // 可选 WebSocket 或 SSE
1616
autoReconnect = true
1717
}
1818
}
19-
}.start() // 不要忘记这里的 start() 调用!
19+
}.start()
2020
```
2121

2222
事件服务连接不会自动建立,你需要手动调用 `connectEvent()` 才会真正开始监听事件。
2323

2424
```kotlin
2525
suspend fun main() {
26-
val client = SaltifyApplication { /* ... */ }
26+
val client = SaltifyApplication { /* ... */ }.start()
2727

2828
client.connectEvent()
2929

saltify-docs/content/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ Saltify 是一个跨平台、可扩展的 Kotlin QQ Bot 框架 & Milky SDK。
1010

1111
## 开始之前
1212

13-
### 添加 `saltify-core` 依赖
13+
### 添加 Saltify 依赖
1414

1515
[![Maven Central](https://img.shields.io/maven-central/v/org.ntqqrev/saltify-core?label=Maven%20Central&logo=maven)](https://central.sonatype.com/artifact/org.ntqqrev/saltify-core)
1616

1717
对于使用 Gradle 的 Kotlin 项目,可以在 `build.gradle.kts` 中添加以下内容:
1818

1919
```kotlin
2020
dependencies {
21+
// 核心模块
2122
implementation("org.ntqqrev:saltify-core:$saltifyVersion")
2223

2324
// 你可以选择为 Ktor client 使用不同的引擎而不是 cio,这里只是一个推荐。

saltify-docs/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"description": "Saltify Documentation",
55
"main": "index.js",
66
"scripts": {
7-
"dev": "next",
8-
"build": "next build",
7+
"extract-version": "node scripts/extract-version.js",
8+
"dev": "pnpm extract-version && next",
9+
"build": "pnpm extract-version && next build",
910
"start": "next start",
1011
"postbuild": "pagefind --site .next/server/app --output-path out/_pagefind"
1112
},
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
// 从 build.gradle.kts 读取版本号
5+
const gradleFile = path.join(__dirname, '../../build.gradle.kts');
6+
const content = fs.readFileSync(gradleFile, 'utf8');
7+
8+
const versionMatch = content.match(/version\s*=\s*"([^"]+)"/);
9+
const version = versionMatch ? versionMatch[1] : 'unknown';
10+
11+
const outputPath = path.join(__dirname, '../app/version.ts');
12+
const output = `export const SALTIFY_VERSION = '${version}';`;
13+
14+
fs.writeFileSync(outputPath, output, 'utf8');

0 commit comments

Comments
 (0)