|
| 1 | +import React from "react"; |
| 2 | + |
| 3 | +import CodeBlock from "@theme/CodeBlock"; |
| 4 | + |
| 5 | +export type Feature = { |
| 6 | + title: string; |
| 7 | + tagline?: string; |
| 8 | + description?: string; |
| 9 | + annotaion?: string; |
| 10 | + children?: React.ReactNode; |
| 11 | +}; |
| 12 | + |
| 13 | +export function HomeFeature({ |
| 14 | + title, |
| 15 | + tagline, |
| 16 | + description, |
| 17 | + annotaion, |
| 18 | + children, |
| 19 | +}: Feature): React.ReactNode { |
| 20 | + return ( |
| 21 | + <div className="flex flex-col items-center justify-center p-4"> |
| 22 | + <p className="text-sm text-base-content/70 font-medium tracking-wide uppercase"> |
| 23 | + {tagline} |
| 24 | + </p> |
| 25 | + <h1 className="mt-3 font-mono font-light text-4xl tracking-tight sm:text-5xl md:text-5xl text-primary"> |
| 26 | + {title} |
| 27 | + </h1> |
| 28 | + <p className="mt-10 mb-6">{description}</p> |
| 29 | + {children} |
| 30 | + <p className="text-sm italic text-base-content/70">{annotaion}</p> |
| 31 | + </div> |
| 32 | + ); |
| 33 | +} |
| 34 | + |
| 35 | +function HomeFeatureSingleColumn(props: Feature): React.ReactNode { |
| 36 | + return ( |
| 37 | + <div className="grid grid-cols-1 px-4 py-8 md:px-16 mx-auto"> |
| 38 | + <HomeFeature {...props} /> |
| 39 | + </div> |
| 40 | + ); |
| 41 | +} |
| 42 | + |
| 43 | +function HomeFeatureDoubleColumn({ |
| 44 | + features: [feature1, feature2], |
| 45 | + children, |
| 46 | +}: { |
| 47 | + features: [Feature, Feature]; |
| 48 | + children?: [React.ReactNode, React.ReactNode]; |
| 49 | +}): React.ReactNode { |
| 50 | + const [children1, children2] = children ?? []; |
| 51 | + |
| 52 | + return ( |
| 53 | + <div className="grid gap-x-6 gap-y-8 grid-cols-1 lg:grid-cols-2 max-w-7xl px-4 py-8 md:px-16 mx-auto"> |
| 54 | + <HomeFeature {...feature1}>{children1}</HomeFeature> |
| 55 | + <HomeFeature {...feature2}>{children2}</HomeFeature> |
| 56 | + </div> |
| 57 | + ); |
| 58 | +} |
| 59 | + |
| 60 | +function HomeFeatures(): React.ReactNode { |
| 61 | + return ( |
| 62 | + <> |
| 63 | + <HomeFeatureSingleColumn |
| 64 | + title="开箱即用" |
| 65 | + tagline="out of box" |
| 66 | + description="使用 NB-CLI 快速构建属于你的机器人" |
| 67 | + > |
| 68 | + <CodeBlock |
| 69 | + title="Installation" |
| 70 | + language="bash" |
| 71 | + className="home-codeblock" |
| 72 | + > |
| 73 | + {[ |
| 74 | + "$ pipx install nb-cli", |
| 75 | + "$ nb", |
| 76 | + // "d8b db .d88b. d8b db d88888b d8888b. .d88b. d888888b", |
| 77 | + // "888o 88 .8P Y8. 888o 88 88' 88 `8D .8P Y8. `~~88~~'", |
| 78 | + // "88V8o 88 88 88 88V8o 88 88ooooo 88oooY' 88 88 88", |
| 79 | + // "88 V8o88 88 88 88 V8o88 88~~~~~ 88~~~b. 88 88 88", |
| 80 | + // "88 V888 `8b d8' 88 V888 88. 88 8D `8b d8' 88", |
| 81 | + // "VP V8P `Y88P' VP V8P Y88888P Y8888P' `Y88P' YP", |
| 82 | + "[?] What do you want to do?", |
| 83 | + "❯ Create a NoneBot project.", |
| 84 | + " Run the bot in current folder.", |
| 85 | + " Manage bot driver.", |
| 86 | + " Manage bot adapters.", |
| 87 | + " Manage bot plugins.", |
| 88 | + " ...", |
| 89 | + ].join("\n")} |
| 90 | + </CodeBlock> |
| 91 | + </HomeFeatureSingleColumn> |
| 92 | + <HomeFeatureDoubleColumn |
| 93 | + features={[ |
| 94 | + { |
| 95 | + title: "插件系统", |
| 96 | + tagline: "plugin system", |
| 97 | + description: "支持插件和执行脚本", |
| 98 | + }, |
| 99 | + { |
| 100 | + title: "跨语言支持", |
| 101 | + tagline: "i18n support", |
| 102 | + description: "支持多种语言,自动识别系统语言", |
| 103 | + }, |
| 104 | + ]} |
| 105 | + > |
| 106 | + <CodeBlock title="" language="python" className="home-codeblock"> |
| 107 | + {[ |
| 108 | + "[project.entry-points.nb]", |
| 109 | + `plugin_name = "cli_plugin.plugin:install"`, |
| 110 | + "[project.entry-points.nb_scripts]", |
| 111 | + `foo = "awesome_bot.module:function"`, |
| 112 | + " " |
| 113 | + ].join("\n")} |
| 114 | + </CodeBlock> |
| 115 | + <CodeBlock title="" language="python" className="home-codeblock"> |
| 116 | + {[ |
| 117 | + "[?] 你想要进行什么操作?", |
| 118 | + "❯ 创建一个 NoneBot 项目.", |
| 119 | + " 管理 bot 插件.", |
| 120 | + " 管理 bot 适配器.", |
| 121 | + " 管理 bot 驱动器.", |
| 122 | + ].join("\n")} |
| 123 | + </CodeBlock> |
| 124 | + </HomeFeatureDoubleColumn> |
| 125 | + </> |
| 126 | + ); |
| 127 | +} |
| 128 | + |
| 129 | +export default React.memo(HomeFeatures); |
0 commit comments