mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-31 01:59:58 +00:00
📝 Docs: 升级新版 NonePress 主题 (#2375)
This commit is contained in:
@ -1,165 +1,13 @@
|
||||
import clsx from "clsx";
|
||||
import React from "react";
|
||||
|
||||
import CodeBlock from "@theme/CodeBlock";
|
||||
import Layout from "@theme/Layout";
|
||||
|
||||
import { Hero, HeroFeature } from "../components/Hero";
|
||||
import type { Feature } from "../components/Hero";
|
||||
import styles from "../css/index.module.css";
|
||||
|
||||
export default function Home() {
|
||||
const firstFeature: Feature = {
|
||||
title: "开箱即用",
|
||||
tagline: "out of box",
|
||||
description: "使用 NB-CLI 快速构建属于你的机器人",
|
||||
} as const;
|
||||
const secondFeatures = [
|
||||
{
|
||||
title: "插件系统",
|
||||
tagline: "plugin system",
|
||||
description: "插件化开发,模块化管理",
|
||||
},
|
||||
{
|
||||
title: "跨平台支持",
|
||||
tagline: "cross-platform support",
|
||||
description: "支持多种平台,以及多样的事件响应方式",
|
||||
},
|
||||
] as const;
|
||||
const thirdFeatures = [
|
||||
{
|
||||
title: "异步开发",
|
||||
tagline: "asynchronous first",
|
||||
description: "异步优先式开发,提高运行效率",
|
||||
},
|
||||
{
|
||||
title: "依赖注入",
|
||||
tagline: "builtin dependency injection system",
|
||||
description: "简单清晰的依赖注入系统,内置依赖函数减少用户代码",
|
||||
},
|
||||
];
|
||||
import HomeContent from "@/components/Home";
|
||||
|
||||
export default function Homepage(): JSX.Element {
|
||||
return (
|
||||
<Layout>
|
||||
<Hero />
|
||||
<div className="max-w-7xl mx-auto py-16 px-4 text-center md:px-16">
|
||||
<HeroFeature {...firstFeature}>
|
||||
<CodeBlock
|
||||
title="Installation"
|
||||
className={clsx("inline-block language-bash", styles.homeCodeBlock)}
|
||||
>
|
||||
{[
|
||||
"$ pip install nb-cli",
|
||||
"$ nb",
|
||||
// "d8b db .d88b. d8b db d88888b d8888b. .d88b. d888888b",
|
||||
// "888o 88 .8P Y8. 888o 88 88' 88 `8D .8P Y8. `~~88~~'",
|
||||
// "88V8o 88 88 88 88V8o 88 88ooooo 88oooY' 88 88 88",
|
||||
// "88 V8o88 88 88 88 V8o88 88~~~~~ 88~~~b. 88 88 88",
|
||||
// "88 V888 `8b d8' 88 V888 88. 88 8D `8b d8' 88",
|
||||
// "VP V8P `Y88P' VP V8P Y88888P Y8888P' `Y88P' YP",
|
||||
"[?] What do you want to do?",
|
||||
"❯ Create a New Project",
|
||||
" Run the Bot in Current Folder",
|
||||
" Driver ->",
|
||||
" Adapter ->",
|
||||
" Plugin ->",
|
||||
" ...",
|
||||
].join("\n")}
|
||||
</CodeBlock>
|
||||
</HeroFeature>
|
||||
</div>
|
||||
<div className="max-w-7xl mx-auto py-16 px-4 md:grid md:grid-cols-2 md:gap-6 md:px-16">
|
||||
<div className="pb-16 text-center md:pb-0">
|
||||
<HeroFeature {...secondFeatures[0]}>
|
||||
<CodeBlock
|
||||
title
|
||||
className={clsx(
|
||||
"inline-block language-python",
|
||||
styles.homeCodeBlock
|
||||
)}
|
||||
>
|
||||
{[
|
||||
"import nonebot",
|
||||
"# 加载一个插件",
|
||||
'nonebot.load_plugin("path.to.your.plugin")',
|
||||
"# 从文件夹加载插件",
|
||||
'nonebot.load_plugins("plugins")',
|
||||
"# 从配置文件加载多个插件",
|
||||
'nonebot.load_from_json("plugins.json")',
|
||||
'nonebot.load_from_toml("pyproject.toml")',
|
||||
].join("\n")}
|
||||
</CodeBlock>
|
||||
</HeroFeature>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<HeroFeature {...secondFeatures[1]}>
|
||||
<CodeBlock
|
||||
title
|
||||
className={clsx(
|
||||
"inline-block language-python",
|
||||
styles.homeCodeBlock
|
||||
)}
|
||||
>
|
||||
{[
|
||||
"import nonebot",
|
||||
"# OneBot",
|
||||
"from nonebot.adapters.onebot.v11 import Adapter as OneBotAdapter",
|
||||
"# 钉钉",
|
||||
"from nonebot.adapters.ding import Adapter as DingAdapter",
|
||||
"driver = nonebot.get_driver()",
|
||||
"driver.register_adapter(OneBotAdapter)",
|
||||
"driver.register_adapter(DingAdapter)",
|
||||
].join("\n")}
|
||||
</CodeBlock>
|
||||
</HeroFeature>
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-w-7xl mx-auto py-16 px-4 md:grid md:grid-cols-2 md:gap-6 md:px-16">
|
||||
<div className="pb-16 text-center md:pb-0">
|
||||
<HeroFeature {...thirdFeatures[0]}>
|
||||
<CodeBlock
|
||||
title
|
||||
className={clsx(
|
||||
"inline-block language-python",
|
||||
styles.homeCodeBlock
|
||||
)}
|
||||
>
|
||||
{[
|
||||
"from nonebot import on_message",
|
||||
"# 注册一个消息响应器",
|
||||
"matcher = on_message()",
|
||||
"# 注册一个消息处理器",
|
||||
"# 并重复收到的消息",
|
||||
"@matcher.handle()",
|
||||
"async def handler(event: Event) -> None:",
|
||||
" await matcher.send(event.get_message())",
|
||||
].join("\n")}
|
||||
</CodeBlock>
|
||||
</HeroFeature>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<HeroFeature {...thirdFeatures[1]}>
|
||||
<CodeBlock
|
||||
title
|
||||
className={clsx(
|
||||
"inline-block language-python",
|
||||
styles.homeCodeBlock
|
||||
)}
|
||||
>
|
||||
{[
|
||||
"from nonebot import on_command",
|
||||
"# 注册一个命令响应器",
|
||||
'matcher = on_command("help", alias={"帮助"})',
|
||||
"# 注册一个命令处理器",
|
||||
"# 通过依赖注入获得命令名以及参数",
|
||||
"@matcher.handle()",
|
||||
"async def handler(cmd = Command(), arg = CommandArg()) -> None:",
|
||||
" await matcher.finish()",
|
||||
].join("\n")}
|
||||
</CodeBlock>
|
||||
</HeroFeature>
|
||||
</div>
|
||||
</div>
|
||||
<HomeContent />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
---
|
||||
description: NoneBot Store
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
import Driver from "../components/Driver";
|
||||
import Adapter from "../components/Adapter";
|
||||
import Plugin from "../components/Plugin";
|
||||
import Bot from "../components/Bot";
|
||||
|
||||
# 商店
|
||||
|
||||
:::warning 警告
|
||||
商店未带有绿色官方标记的任何适配器、插件均由社区贡献,官方无法对其质量、安全性、可用性负责。
|
||||
:::
|
||||
|
||||
<div className="w-full border rounded shadow">
|
||||
<Tabs defaultValue="plugin" className="justify-center font-light">
|
||||
<TabItem value="driver" label="驱动器">
|
||||
<Driver />
|
||||
</TabItem>
|
||||
<TabItem value="adapter" label="适配器">
|
||||
<Adapter />
|
||||
</TabItem>
|
||||
<TabItem value="plugin" label="插件">
|
||||
<Plugin />
|
||||
</TabItem>
|
||||
<TabItem value="bot" label="机器人">
|
||||
<Bot />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
</div>
|
20
website/src/pages/store/adapters.tsx
Normal file
20
website/src/pages/store/adapters.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
|
||||
import { translate } from "@docusaurus/Translate";
|
||||
|
||||
import AdapterPageContent from "@/components/Store/Content/Adapter";
|
||||
import StoreLayout from "@/components/Store/Layout";
|
||||
|
||||
export default function StoreAdapters(): JSX.Element {
|
||||
const title = translate({
|
||||
id: "pages.store.adapter.title",
|
||||
message: "适配器商店",
|
||||
description: "Title for the adapter store page",
|
||||
});
|
||||
|
||||
return (
|
||||
<StoreLayout title={title}>
|
||||
<AdapterPageContent />
|
||||
</StoreLayout>
|
||||
);
|
||||
}
|
20
website/src/pages/store/bots.tsx
Normal file
20
website/src/pages/store/bots.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
|
||||
import { translate } from "@docusaurus/Translate";
|
||||
|
||||
import BotPageContent from "@/components/Store/Content/Bot";
|
||||
import StoreLayout from "@/components/Store/Layout";
|
||||
|
||||
export default function StoreBots(): JSX.Element {
|
||||
const title = translate({
|
||||
id: "pages.store.bot.title",
|
||||
message: "机器人商店",
|
||||
description: "Title for the bot store page",
|
||||
});
|
||||
|
||||
return (
|
||||
<StoreLayout title={title}>
|
||||
<BotPageContent />
|
||||
</StoreLayout>
|
||||
);
|
||||
}
|
20
website/src/pages/store/drivers.tsx
Normal file
20
website/src/pages/store/drivers.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
|
||||
import { translate } from "@docusaurus/Translate";
|
||||
|
||||
import DriverPageContent from "@/components/Store/Content/Driver";
|
||||
import StoreLayout from "@/components/Store/Layout";
|
||||
|
||||
export default function StoreDrivers(): JSX.Element {
|
||||
const title = translate({
|
||||
id: "pages.store.driver.title",
|
||||
message: "驱动器商店",
|
||||
description: "Title for the driver store page",
|
||||
});
|
||||
|
||||
return (
|
||||
<StoreLayout title={title}>
|
||||
<DriverPageContent />
|
||||
</StoreLayout>
|
||||
);
|
||||
}
|
7
website/src/pages/store/index.tsx
Normal file
7
website/src/pages/store/index.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { Redirect } from "@docusaurus/router";
|
||||
|
||||
export default function Store(): JSX.Element {
|
||||
return <Redirect to="/store/plugins" />;
|
||||
}
|
20
website/src/pages/store/plugins.tsx
Normal file
20
website/src/pages/store/plugins.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
|
||||
import { translate } from "@docusaurus/Translate";
|
||||
|
||||
import PluginPageContent from "@/components/Store/Content/Plugin";
|
||||
import StoreLayout from "@/components/Store/Layout";
|
||||
|
||||
export default function StorePlugins(): JSX.Element {
|
||||
const title = translate({
|
||||
id: "pages.store.plugin.title",
|
||||
message: "插件商店",
|
||||
description: "Title for the plugin store page",
|
||||
});
|
||||
|
||||
return (
|
||||
<StoreLayout title={title}>
|
||||
<PluginPageContent />
|
||||
</StoreLayout>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user