From ac4def78b1c16762589a24c16bb74eabfdb16981 Mon Sep 17 00:00:00 2001 From: "ren.siwei3" Date: Fri, 27 Oct 2023 15:46:25 +0800 Subject: [PATCH] @feature: remove config.dev, use env DEPLOY_PLATFORM --- docusaurus.config.dev.js | 182 -------------------------------------- docusaurus.config.js | 10 ++- package-lock.json | 31 ++++++- package.json | 7 +- src/pages/market/index.js | 3 +- static/contants.js | 18 ++++ 6 files changed, 61 insertions(+), 190 deletions(-) delete mode 100644 docusaurus.config.dev.js create mode 100644 static/contants.js diff --git a/docusaurus.config.dev.js b/docusaurus.config.dev.js deleted file mode 100644 index cd889cbc6..000000000 --- a/docusaurus.config.dev.js +++ /dev/null @@ -1,182 +0,0 @@ -// @ts-check -// Note: type annotations allow type checking and IDEs autocompletion - -const lightCodeTheme = require('prism-react-renderer/themes/github'); -const darkCodeTheme = require('prism-react-renderer/themes/dracula'); -const href_pre = 'https://docs.tenxcloud.com'; - -/** @type {import('@docusaurus/types').Config} */ -const config = { - title: 'Framework as a Building Block for Kubernetes', - tagline: '在 Kubernetes 上以搭积木的方式构建自己的服务门户', - favicon: 'img/favicon.png', - - // Set the production url of your site here - url: 'https://kubebb.github.io', - // Set the // pathname under which your site is served - // For GitHub pages deployment, it is often '//' - baseUrl: '/website', - - // GitHub pages deployment config. - // If you aren't using GitHub pages, you don't need these. - organizationName: 'kubebb', // Usually your GitHub org/user name. - projectName: 'kubebb', // Usually your repo name. - - onBrokenLinks: 'throw', - onBrokenMarkdownLinks: 'warn', - - // Even if you don't use internalization, you can use this field to set useful - // metadata like html lang. For example, if your site is Chinese, you may want - // to replace "en" with "zh-Hans". - i18n: { - defaultLocale: 'zh-Hans', - locales: ['zh-Hans', 'en'], - localeConfigs: { - en: { - label: 'English', - }, - 'zh-Hans': { - label: '中文', - }, - }, - }, - - presets: [ - [ - 'classic', - /** @type {import('@docusaurus/preset-classic').Options} */ - ({ - docs: { - sidebarPath: require.resolve('./sidebars.js'), - }, - theme: { - customCss: require.resolve('./src/css/custom.css'), - }, - }), - ], - ], - - themeConfig: - /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ - ({ - // Replace with your project's social card - image: 'img/docusaurus-social-card.jpg', - navbar: { - title: '', - logo: { - alt: 'Kubebb Logo', - src: "img/kubebb-logo-black.svg", - srcDark: "img/kubebb-logo-white.svg", - }, - items: [ - { - type: 'doc', - docId: 'intro', - position: 'left', - label: '文档中心', - }, - { - to: '/market', - position: 'left', - label: '组件市场', - }, - { - href: 'https://github.com/kubebb/', - className: 'noIcon', - label: 'GitHub', - position: 'left', - }, - { - href: 'https://dev.tenxcloud.com/', - className: 'noIcon', - position: 'left', - label: '开发者社区', - }, - /*{to: '/blog', label: 'Blog', position: 'left'},*/ - { - type: 'localeDropdown', - position: 'right', - }, - ], - }, - footer: { - style: 'light', - links: [ - { - title: 'Kubebb', - items: [ - { - label: '快速开始', - to: '/docs/quick-start/prerequisite', - }, - { - label: '内核 Kit', - to: '/docs/core/intro', - }, - { - label: '底座 Kit', - to: '/docs/building-base/intro', - }, - { - label: '低码 Kit', - to: '/docs/lowcode-development/intro', - }, - ], - }, - { - title: '开源产品', - items: [ - { - label: '微服务框架', - href: href_pre + '/docs/TMF/产品介绍', - }, - { - label: '服务网格', - href: href_pre + '/docs/服务网格/产品介绍', - }, - { - label: 'API网关', - href: href_pre + '/docs/TAMP/产品介绍', - }, - { - label: '应用性能监控', - href: href_pre + '/docs/TAPM/产品介绍', - }, - { - label: '云梯低代码平台', - to: '/docs/lowcode-development/intro', - }, - ], - }, - { - title: '更多信息', - items: [ - { - label: 'Github issue', - href: 'https://github.com/kubebb/core/issues', - }, - { - label: 'Github', - href: 'https://github.com/kubebb', - }, - ], - }, - { - title: '加入我们', - items: [ - { - html: `` - } - ] - }, - ], - copyright: `Copyright © ${new Date().getFullYear()} KubeBB`, - }, - prism: { - theme: lightCodeTheme, - darkTheme: darkCodeTheme, - }, - }), -}; - -module.exports = config; diff --git a/docusaurus.config.js b/docusaurus.config.js index d5ce43ea3..3af9c177d 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -3,8 +3,11 @@ const lightCodeTheme = require('prism-react-renderer/themes/github'); const darkCodeTheme = require('prism-react-renderer/themes/dracula'); +const { curr_url_map } = require('./static/contants.js'); const href_pre = 'https://docs.tenxcloud.com'; +console.log('curr_url_map', curr_url_map) + /** @type {import('@docusaurus/types').Config} */ const config = { title: 'Framework as a Building Block for Kubernetes', @@ -12,10 +15,10 @@ const config = { favicon: 'img/favicon.png', // Set the production url of your site here - url: 'http://kubebb.k8s.com.cn', + url: curr_url_map?.url || 'http://kubebb.k8s.com.cn', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: '/', + baseUrl: curr_url_map?.baseUrl || '/', // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. @@ -165,7 +168,8 @@ const config = { title: '加入我们', items: [ { - html: `` + html: `` } ] }, diff --git a/package-lock.json b/package-lock.json index 608973a21..9d5c732e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ "react-dom": "^17.0.2" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.4.0" + "@docusaurus/module-type-aliases": "2.4.0", + "cross-env": "^7.0.3" }, "engines": { "node": ">=16.14" @@ -5029,6 +5030,25 @@ "node": ">=10" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "http://dev-npm.tenxcloud.net/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha1-hlJkspZ33AFbqEGJGJZd0jL8VM8=", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-fetch": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", @@ -16308,6 +16328,15 @@ "yaml": "^1.10.0" } }, + "cross-env": { + "version": "7.0.3", + "resolved": "http://dev-npm.tenxcloud.net/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha1-hlJkspZ33AFbqEGJGJZd0jL8VM8=", + "dev": true, + "requires": { + "cross-spawn": "^7.0.1" + } + }, "cross-fetch": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", diff --git a/package.json b/package.json index 5f4fdbad5..4f80a627e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "docusaurus": "docusaurus", "start": "docusaurus start", "build": "docusaurus build", - "build-dev": "docusaurus build --config docusaurus.config.dev.js", + "build-dev": "cross-env DEPLOY_PLATFORM=github docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", @@ -24,7 +24,8 @@ "react-dom": "^17.0.2" }, "devDependencies": { - "@docusaurus/module-type-aliases": "2.4.0" + "@docusaurus/module-type-aliases": "2.4.0", + "cross-env": "^7.0.3" }, "browserslist": { "production": [ @@ -41,4 +42,4 @@ "engines": { "node": ">=16.14" } -} \ No newline at end of file +} diff --git a/src/pages/market/index.js b/src/pages/market/index.js index e52dd1187..7f59a5719 100644 --- a/src/pages/market/index.js +++ b/src/pages/market/index.js @@ -10,6 +10,7 @@ import Tdsf from '../../../static/img/market/tdsf.svg'; import Layout from '@theme/Layout'; import styles from './index.module.css'; import { useHistory } from '@docusaurus/router'; +import { curr_url_map } from '../../../static/contants'; const href_pre = 'https://docs.tenxcloud.com'; const data = [ @@ -95,7 +96,7 @@ const data = [ icon: , tag: 'official', types: [ 'dev-tool' ], - to: '/docs/lowcode-development/intro', + to: (curr_url_map?.baseUrl === '/' || !curr_url_map.baseUrl ? '' : curr_url_map.baseUrl) + '/docs/lowcode-development/intro', new: true, bottoms: [ { diff --git a/static/contants.js b/static/contants.js new file mode 100644 index 000000000..ab081bbc3 --- /dev/null +++ b/static/contants.js @@ -0,0 +1,18 @@ +const urlMaps = { + github: { + url: 'https://kubebb.github.io', + baseUrl: '/website', + }, + cn: { + url: 'http://kubebb.k8s.com.cn', + baseUrl: '/', + }, + test: { + url: 'http://kubebb.k8s.com.cn', + baseUrl: '/test', + }, +}; + +exports.urlMaps = urlMaps; + +exports.curr_url_map = urlMaps[process.env.DEPLOY_PLATFORM || 'cn'] \ No newline at end of file