|
| 1 | +import { themes } from "prism-react-renderer"; |
| 2 | +import math from "remark-math"; |
| 3 | +import katex from "rehype-katex"; |
| 4 | +import chHeader from "./plugins/header.js"; |
| 5 | +import fixLinks from "./src/hooks/fixLinks.js"; |
| 6 | + |
| 7 | +// Helper function to skip over index.md files. |
| 8 | +function skipIndex(items) { |
| 9 | + return items.filter(({ type, id }) => { |
| 10 | + return type !== "doc" || !id.match(/index$/); |
| 11 | + }); |
| 12 | +} |
| 13 | + |
| 14 | +/** @type {import('@docusaurus/types').Config} */ |
| 15 | +const config = { |
| 16 | + scripts: [ |
| 17 | + { |
| 18 | + src: "https://widget.kapa.ai/kapa-widget.bundle.js", |
| 19 | + "data-website-id": "c0b5f156-1e92-49df-8252-adacc9feb21b", |
| 20 | + "data-project-name": "ClickHouse", |
| 21 | + "data-project-color": "#151515", |
| 22 | + "data-project-logo": |
| 23 | + "https://avatars.githubusercontent.com/u/54801242?s=200&v=4", |
| 24 | + "data-modal-disclaimer": |
| 25 | + "这是一个为ClickHouse定制的LLM,能够访问所有开发者文档、公开的GitHub问题、YouTube视频和已解决的StackOverflow帖子。请注意,答案由AI生成,可能并不完全准确,因此请根据您的判断使用这些信息。", |
| 26 | + "data-modal-example-questions": |
| 27 | + "如何加速查询?,如何使用物化视图?", |
| 28 | + "data-kapa-branding-hide": "true", |
| 29 | + async: true, |
| 30 | + defer: true, // execute after document parsing, but before firing DOMContentLoaded event |
| 31 | + }, |
| 32 | + ], |
| 33 | + // Settings for Docusaurus Faster - build optimizations |
| 34 | + future: { |
| 35 | + experimental_faster: { |
| 36 | + swcJsLoader: true, |
| 37 | + swcJsMinimizer: true, |
| 38 | + swcHtmlMinimizer: true, |
| 39 | + lightningCssMinimizer: true, |
| 40 | + rspackBundler: true, |
| 41 | + mdxCrossCompilerCache: true, |
| 42 | + }, |
| 43 | + }, |
| 44 | + title: "ClickHouse Docs", |
| 45 | + tagline: |
| 46 | + "我们提供文档、快速入门指南、用户指南、技术参考、常见问题解答等多种信息。", |
| 47 | + url: "https://clickhouse.com", |
| 48 | + // url: process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'https://bookish-disco-5997zvo.pages.github.io', |
| 49 | + baseUrl: "/docs/zh/", |
| 50 | + baseUrlIssueBanner: true, |
| 51 | + onBrokenLinks: "warn", |
| 52 | + onBrokenMarkdownLinks: "warn", |
| 53 | + onDuplicateRoutes: "throw", |
| 54 | + onBrokenAnchors: "warn", |
| 55 | + favicon: "img/docs_favicon.ico", |
| 56 | + organizationName: "ClickHouse", |
| 57 | + trailingSlash: false, |
| 58 | + i18n: { |
| 59 | + defaultLocale: "zh", |
| 60 | + locales: ["zh", "en"], |
| 61 | + path: "i18n", |
| 62 | + localeConfigs: { |
| 63 | + ru: { |
| 64 | + label: "Russian", |
| 65 | + htmlLang: "ru", |
| 66 | + path: "ru", |
| 67 | + }, |
| 68 | + en: { |
| 69 | + label: "English", |
| 70 | + htmlLang: "en", |
| 71 | + path: "en", |
| 72 | + }, |
| 73 | + jp: { |
| 74 | + label: "Japanese", |
| 75 | + htmlLang: "jp", |
| 76 | + path: "jp", |
| 77 | + }, |
| 78 | + zh: { |
| 79 | + label: "Chinese", |
| 80 | + htmlLang: "zh", |
| 81 | + path: "zh", |
| 82 | + }, |
| 83 | + }, |
| 84 | + }, |
| 85 | + staticDirectories: ["static"], |
| 86 | + projectName: "clickhouse-docs", |
| 87 | + markdown: { |
| 88 | + mermaid: true, |
| 89 | + }, |
| 90 | + themes: ["@docusaurus/theme-mermaid"], |
| 91 | + presets: [ |
| 92 | + [ |
| 93 | + "classic", |
| 94 | + /** @type {import('@docusaurus/preset-classic').Options} */ |
| 95 | + ({ |
| 96 | + docs: { |
| 97 | + admonitions: { |
| 98 | + keywords: [ |
| 99 | + "note", |
| 100 | + "tip", |
| 101 | + "info", |
| 102 | + "caution", |
| 103 | + "danger", |
| 104 | + "experimental", |
| 105 | + "obsolete", |
| 106 | + "warning", |
| 107 | + "success", |
| 108 | + "important", |
| 109 | + "secondary", |
| 110 | + ], |
| 111 | + }, |
| 112 | + sidebarPath: require.resolve("./sidebars.js"), |
| 113 | + // Implements a custom sidebar to override default behaviour where index.md page shows underneath the category name. |
| 114 | + // With this sidebar the category name is clickable to show the index.md contents. |
| 115 | + async sidebarItemsGenerator({ |
| 116 | + defaultSidebarItemsGenerator, |
| 117 | + ...args |
| 118 | + }) { |
| 119 | + const sidebarItems = await defaultSidebarItemsGenerator(args); |
| 120 | + return skipIndex(sidebarItems); |
| 121 | + }, |
| 122 | + editCurrentVersion: false, |
| 123 | + breadcrumbs: true, |
| 124 | + showLastUpdateTime: false, |
| 125 | + sidebarCollapsed: true, |
| 126 | + routeBasePath: "/", |
| 127 | + remarkPlugins: [math], |
| 128 | + beforeDefaultRemarkPlugins: [fixLinks], |
| 129 | + rehypePlugins: [katex], |
| 130 | + }, |
| 131 | + blog: { |
| 132 | + path: "knowledgebase", |
| 133 | + blogTitle: "ClickHouse 知识库", |
| 134 | + blogDescription: "知识库", |
| 135 | + blogSidebarTitle: "所有KB文章", |
| 136 | + routeBasePath: "/knowledgebase", |
| 137 | + postsPerPage: 10, |
| 138 | + blogSidebarCount: "ALL", |
| 139 | + feedOptions: { |
| 140 | + type: "all", |
| 141 | + title: "ClickHouse 知识库信息流", |
| 142 | + description: "在ClickHouse知识库中发布的文章信息流", |
| 143 | + copyright: `Copyright © 2016–${new Date().getFullYear()} ClickHouse, Inc. ClickHouse Docs provided under the Creative Commons CC BY-NC-SA 4.0 license. ClickHouse® is a registered trademark of ClickHouse, Inc.`, |
| 144 | + language: "en", |
| 145 | + createFeedItems: async (params) => { |
| 146 | + const { blogPosts, defaultCreateFeedItems, ...rest } = params; |
| 147 | + return defaultCreateFeedItems({ |
| 148 | + // keep only the 10 most recent blog posts in the feed |
| 149 | + blogPosts: blogPosts.filter((item, index) => index < 10), |
| 150 | + ...rest, |
| 151 | + }); |
| 152 | + }, |
| 153 | + }, |
| 154 | + editUrl: ({ blogPath }) => { |
| 155 | + return ( |
| 156 | + "https://github.com/ClickHouse/clickhouse-docs/blob/main/knowledgebase/" + |
| 157 | + blogPath |
| 158 | + ); |
| 159 | + }, |
| 160 | + }, |
| 161 | + theme: { |
| 162 | + customCss: [require.resolve("./src/css/custom.scss")], |
| 163 | + }, |
| 164 | + gtag: { |
| 165 | + trackingID: "G-KF1LLRTQ5Q", |
| 166 | + }, |
| 167 | + }), |
| 168 | + ], |
| 169 | + ], |
| 170 | + // Inserts tags into the <head></head> |
| 171 | + headTags: [ |
| 172 | + { |
| 173 | + // Ask AI component |
| 174 | + tagName: "link", |
| 175 | + attributes: { |
| 176 | + href: "https://widget.kapa.ai", |
| 177 | + rel: "preconnect", // preemptively initiate a connection to resource |
| 178 | + }, |
| 179 | + }, |
| 180 | + { |
| 181 | + // Google's CDN. Caches all 'static' files in a server near to you |
| 182 | + // to reduce load times. |
| 183 | + tagName: "link", |
| 184 | + attributes: { |
| 185 | + href: "https://www.gstatic.com", |
| 186 | + rel: "preconnect", |
| 187 | + crossorigin: "use-credentials", |
| 188 | + }, |
| 189 | + }, |
| 190 | + { |
| 191 | + tagName: "link", |
| 192 | + attributes: { |
| 193 | + href: "https://www.googletagmanager.com", |
| 194 | + rel: "preconnect", |
| 195 | + }, |
| 196 | + }, |
| 197 | + ], |
| 198 | + themeConfig: |
| 199 | + /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ |
| 200 | + ({ |
| 201 | + algolia: { |
| 202 | + appId: "5H9UG7CX5W", |
| 203 | + apiKey: "4a7bf25cf3edbef29d78d5e1eecfdca5", |
| 204 | + indexName: "clickhouse", |
| 205 | + contextualSearch: false, |
| 206 | + searchPagePath: "search", |
| 207 | + }, |
| 208 | + image: "img/docs_social_share.png", |
| 209 | + icon: "/img/gareth.png", |
| 210 | + docs: { |
| 211 | + sidebar: { |
| 212 | + autoCollapseCategories: true, |
| 213 | + }, |
| 214 | + }, |
| 215 | + // autoCollapseSidebarCategories: true, |
| 216 | + navbar: { |
| 217 | + hideOnScroll: false, |
| 218 | + logo: { |
| 219 | + alt: "ClickHouse", |
| 220 | + src: "img/ch_logo_docs.svg", |
| 221 | + srcDark: "img/ch_logo_docs_dark.svg", |
| 222 | + href: "https://clickhouse.com/", |
| 223 | + }, |
| 224 | + items: [], |
| 225 | + }, |
| 226 | + footer: { |
| 227 | + style: "light", |
| 228 | + links: [ |
| 229 | + { |
| 230 | + label: "商标", |
| 231 | + to: "https://clickhouse.com/legal/trademark-policy", |
| 232 | + }, |
| 233 | + { |
| 234 | + label: "隐私", |
| 235 | + to: "https://clickhouse.com/legal/privacy-policy", |
| 236 | + }, |
| 237 | + { |
| 238 | + label: "安全", |
| 239 | + to: "https://trust.clickhouse.com/", |
| 240 | + }, |
| 241 | + { |
| 242 | + label: "服务条款", |
| 243 | + to: "https://clickhouse.com/legal/agreements/terms-of-service", |
| 244 | + }, |
| 245 | + ], |
| 246 | + copyright: `© 2016–${new Date().getFullYear()} ClickHouse, Inc.`, |
| 247 | + }, |
| 248 | + prism: { |
| 249 | + theme: themes.darkTheme, |
| 250 | + darkTheme: themes.darkTheme, |
| 251 | + additionalLanguages: ["java", "cpp", "rust"], |
| 252 | + magicComments: [ |
| 253 | + // Remember to extend the default highlight class name as well! |
| 254 | + { |
| 255 | + className: "theme-code-block-highlighted-line", |
| 256 | + line: "highlight-next-line", |
| 257 | + block: { start: "highlight-start", end: "highlight-end" }, |
| 258 | + }, |
| 259 | + ], |
| 260 | + }, |
| 261 | + colorMode: { |
| 262 | + disableSwitch: false, |
| 263 | + respectPrefersColorScheme: true, |
| 264 | + defaultMode: "dark", |
| 265 | + }, |
| 266 | + }), |
| 267 | + |
| 268 | + plugins: [ |
| 269 | + "docusaurus-plugin-sass", |
| 270 | + function (context, options) { |
| 271 | + return { |
| 272 | + name: "docusaurus-plugin", |
| 273 | + async postBuild({ siteConfig = {}, routesPaths = [], outDir }) { |
| 274 | + // Print out to console all the rendered routes. |
| 275 | + routesPaths.map((route) => { |
| 276 | + //console.log(route) |
| 277 | + }); |
| 278 | + }, |
| 279 | + }; |
| 280 | + }, |
| 281 | + [ |
| 282 | + "vercel-analytics", |
| 283 | + { |
| 284 | + debug: false, |
| 285 | + mode: "auto", |
| 286 | + }, |
| 287 | + ], |
| 288 | + chHeader, |
| 289 | + ], |
| 290 | + customFields: { |
| 291 | + blogSidebarLink: "/docs/knowledgebase", // Used for KB article page |
| 292 | + galaxyApiEndpoint: |
| 293 | + process.env.NEXT_PUBLIC_GALAXY_API_ENDPOINT || "http://localhost:3000", |
| 294 | + secondaryNavItems: [ |
| 295 | + { |
| 296 | + type: "dropdown", |
| 297 | + hoverable: "false", |
| 298 | + html: |
| 299 | + '<svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n' + |
| 300 | + '<path d="M6.95 12.6496L9.75 5.26628H11.0333L13.8333 12.6496H12.55L11.9 10.7663H8.91667L8.25 12.6496H6.95ZM9.28333 9.69961H11.5L10.4167 6.64961H10.3667L9.28333 9.69961ZM2.08333 10.7996L1.21667 9.93294L4.33333 6.83294C3.94444 6.39961 3.60556 5.95228 3.31667 5.49094C3.02778 5.03005 2.77222 4.54405 2.55 4.03294H3.83333C4.02222 4.41072 4.22222 4.74672 4.43333 5.04094C4.64444 5.33561 4.89444 5.64405 5.18333 5.96628C5.63889 5.47739 6.01667 4.97472 6.31667 4.45828C6.61667 3.94139 6.86667 3.3885 7.06667 2.79961H0.25V1.58294H4.55V0.349609H5.78333V1.58294H10.0833V2.79961H8.3C8.07778 3.53294 7.78333 4.24116 7.41667 4.92428C7.05 5.60783 6.59444 6.25516 6.05 6.86628L7.53333 8.36628L7.06667 9.63294L5.16667 7.73294L2.08333 10.7996Z" fill="currentColor"/>\n' + |
| 301 | + "</svg>", |
| 302 | + position: "right", |
| 303 | + items: [ |
| 304 | + { |
| 305 | + label: "English", |
| 306 | + to: "/", |
| 307 | + }, |
| 308 | + ], |
| 309 | + }, |
| 310 | + ], |
| 311 | + }, |
| 312 | +}; |
| 313 | + |
| 314 | +module.exports = config; |
0 commit comments