{"id":18408395,"url":"https://github.com/pingcap/community-website","last_synced_at":"2025-04-07T09:32:53.468Z","repository":{"id":47082096,"uuid":"323210869","full_name":"pingcap/community-website","owner":"pingcap","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-14T11:59:44.000Z","size":5878,"stargazers_count":2,"open_issues_count":1,"forks_count":5,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-22T16:02:22.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"community-website-pingcap-community.vercel.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pingcap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-21T02:30:15.000Z","updated_at":"2021-09-10T07:55:55.000Z","dependencies_parsed_at":"2022-09-10T19:10:55.961Z","dependency_job_id":null,"html_url":"https://github.com/pingcap/community-website","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fcommunity-website","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fcommunity-website/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fcommunity-website/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pingcap%2Fcommunity-website/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pingcap","download_url":"https://codeload.github.com/pingcap/community-website/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247626458,"owners_count":20969307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T03:18:58.154Z","updated_at":"2025-04-07T09:32:52.644Z","avatar_url":"https://github.com/pingcap.png","language":"JavaScript","readme":"# TiDB Developer Community - website\n\n[![Netlify Status](https://api.netlify.com/api/v1/badges/bcc3f001-7721-4584-abb8-937c89723fed/deploy-status)](https://app.netlify.com/sites/community-website/deploys)\n[![CircleCI Status](https://circleci.com/gh/pingcap/community-website.svg?style=svg)](https://circleci.com/gh/pingcap/community-website)\n\n## 🚀 Quick start\n\n    git clone git@github.com:pingcap/community-website.git\n    cd community-website\n    npm start\n\n## Data and i18n\n\n`src/data` is the data directory,\nthere are some JavaScript files only export an object with i18n copywriting.\n\nIts content likes\n\n    {\n        en: {...},\n        zh: {...},\n    }\n\n## copy-writing\n\n## navbar\n\n- src/data/navbar.js\n\n## footer\n\n- src/data/footer.js\n- src/data/socials.js\n\n### /\n\n- src/data/home.js\n\n### /people/${people_level}\n\n#### people list\n\n- https://bots.tidb.io/ti-community-bot/members?level=${people_level}\n\n#### markdown\n\n- src/data/people/${people_level}.md\n\n### /sig\n\n- https://bots.tidb.io/ti-community-bot/sigs\n\n### /sig/${sig_name}\n\n- https://bots.tidb.io/ti-community-bot/sigs/${sig_name}\n- markdown-pages/SIGReadme/${sig_name}.md ( download from https://raw.githubusercontent.com/pingcap/community/master/special-interest-groups/sig-${sig_name}/README.md )\n\n### /incubator\n\n- src/data/en/incubator\n\n### /zh/incubator\n\n- src/data/zh/incubator\n\n### /events\n\n- src/data/events.js\n\n## Directory Structure\n\n### images\n\n部分图片资源通过 `gatsby-source-filesystem` 插件进行索引，\n在 component 中通过 graphql 进行查询。\n\n但是也可以通过 JavaScript 的 import 或者 require 直接导入，\n通过这种方式导入同样会被 webpack 打包并且生成带有 hash 缓存标识符的资源文件。\n和 graphql 查询导入的区别在于可能会失去某些优化手段，目前我们的图片尺寸都还不算太大，\n为了方便数据管理，可以按需灵活选择两种引入图片的方式\n\n### src/pages\n\ngatsby.js 默认的页面 component 存放路径，URL 路由规则也按照该文件夹下的文件系统进行生成。\npages 目录名禁止修改。否则默认配置下 gatsby.js 将无法找到页面文件。\n\n### src/component\n\n页面中会重复使用的 component 存放路径。\n\n#### src/component/Container\n\n页面容器组件，用于包裹页面元素，默认情况下居中\n其中又分为 normal 容器和 fluid 容器\n\n- normal 容器的宽度通过媒体查询，根据响应式布局的规则进行自适应调整。左右边距为 1rem （实际尺寸请参考源码）\n- fluid 容器的宽度为 100% （忽略滚动条的情况下也可以为 100vw）。左右边距通过媒体查询，根据响应式布局的规则进行自适应调整。\n\n#### src/component/Layout\n\n页面布局组件，会在页面的顶部和底部自动导入 header 和 footer\n\n#### src/component/SEO\n\nmetadata 数据注入组件，通过 react-helmet 自动像 HTML 文档的 head 部分注入 SEO 相关标签\n\n### src/styles\n\n自定义的样式目录，存放公共样式以及 sass 的部分变量声明\n\n#### src/styles/global.scss\n\n该样式会被 `gatsby-browser.js` 注入至全局页面，\n因此该样式文件里面的样式均具有副作用，而非存放变量声明的地方\n\n#### src/styles/\\_variable.scss\n\n该文件存放各种 sass 变量声明，因此该样式文件里面的样式**不允许**有副作用。\n请勿在该文件中直接写任何选择器以及样式。\n\n#### src/styles/\\_typography.scss\n\n该文件存放各类字体排版的 mixin 声明\n\n#### src/styles/\\_markdown.scss\n\n该文件存放针对 gatsby.js markdown 渲染器自动生成的 HTML 的样式声明\n\n#### src/styles/\\_responsive.scss\n\n该文件存放有关响应式布局的变量以及媒体查询有关的 mixin\n\n#### src/styles/\\_common.scss\n\n该文件为公共 import 文件，可被任何 sass 样式文件使用 `import` 指令导入。\n该文件仅供导入，以及导入其他声明（`@import`指令），因此**不允许**有副作用，也**不允许**有任何声明。\n请勿在该文件中直接写任何选择器以及样式。\n\n### src/data\n\n存放页面文案，统一使用 JavaScript 文件，以便使用注释等 ECMAScript 6 语法具有的高级特性。\n这些文件仅仅只能使用 `export default` 默认导出一个 js object，该 object 的结构应该为\n\n    {\n        // 该页面对应的英文文案\n        en: {...},\n        // 该页面对应的中文文案\n        zh: {...},\n    }\n\n请注意，这里的 `en` 和 `zh` 必须符合 locale 缩写规范，\n否则 `react-intl` 将无法正确根据当前客户端的首选语言选择合适的文案数据填充页面以及渲染。\n\n### src/create-pages\n\ngatsby.js 框架支持直接在 `src/pages` 目录中存放通过 React 组件导出的页面文件，\n也支持在 build 过程中通过 JavaScript 脚本构建页面。\n\n该目录存放用于通过 JavaScript 构建页面的脚本文件。\n这些脚本文件将在 `gatsby-node.js` 中导出的 `createPages` 函数所调用，用于在 build 时生成页面。\n\n通常我们的页面大致结构都一致，只是数据或者国际化文案不一样。\n因此可以通过同一套 template 生成不同语言或者不同数据的页面。\n\n#### src/create-pages/wrapPage.js\n\n存放 React 根组件被包裹的标签，通常用于注入 React.Context ，\n例如 react-intl 的 provider 需要在此处注入\n\n#### src/create-pages/apiHelper.js\n\n存放从 HTTP API 中获取数据的业务逻辑。\n\n##### async function cacheGitHubAvatar(username)\n\n该函数将通过 github 用户名获取该用户的头像\n并且缓存在 `public/cache/github-avatar` 目录中\n因此该项目中涉及到需要显示 github 用户头像的逻辑，需要在 gatsby-node.js 中缓存该头像\n并且在 HTML 中直接引用该目录下的缓存头像，以免中国大陆境内用户无法正常显示 github 头像\n\n该函数的缓存策略为：判断最后修改时间若距离当前时间大于 7 天则强制重新下载一遍 github 头像并覆盖缓存，否则不作任何操作。\n\n#### src/create-pages/templates\n\n存放用于通过 JavaScript 脚本构建页面的页面模版文件，写法与 pages 中的文件类似。\n更多详情可参考 gatsby.js 文档。\n\n### src/helper.js\n\n一些助手函数\n\n### gatsby-\\*.js\n\n#### gatsby-config.js\n\n存放站点的各种配置以及插件配置，具体请参考 gatsby.js 文档。\n\n#### gatsby-node.js\n\n由于本站点有部分数据为动态生成，需要通过 HTTP API 获取数据并且填充 template 文件，\n因此需要 在 gatsby-node 中导入相关业务逻辑。\n构建流程如下\n\n1. 导出 onCreateWebpackConfig 函数用于重写 webpack 配置\n1. 导出 createPages 函数用于动态创建页面\n\n这些被导出的函数类似于 hook ，将会再 gatsby.js 的构建过程中自动被执行\n\n其中 createPages 又通过 Promise.all 分发了多个异步函数用于从 API 中获取数据并且填充模板，然后动态创建页面\n\n### lang.config.js\n\n语言配置，存放默认语言，以及可使用的语言列表（用于在 footer 中进行语言切换）\n\n## Deploy\n\n在 `.circleci/config.yml` 中存放了 CI 构建配置\n\n当前配置情况如下\n\n- 只构建 main 分支\n- 使用 node.js v14.13.0 版本\n- 安装 rsync 用于同步构建结果，sshpass 用于在 ssh 中传递密码\n- 执行 npm install 安装依赖\n- 执行 npm run download 下载一些来自 github 的 markdown 的文件\n- 设置环境变量 GATSBY_CPU_COUNT 用于解决某些情况下的构建 BUG\n- 执行 npm run build 构建纯静态 HTML 页面文件\n- 执行 rsync 命令将构建好的 HTML 页面文件同步到生产环境服务器中\n- 服务器使用 nginx ，配置文件在 `/etc/nginx/nginx.conf` ，\n  根据配置文件中的 root 项，在 CircleCI 中将构建结果文件同步至对应路径。\n\n该站点当前 nginx 配置如下\n\n    server {\n        listen          80;\n        listen          [::]:80;\n        server_name     developer.tidb.io;\n        rewrite ^(.*)$  https://$host$1 permanent;\n        # return 302 https://$host$request_uri;\n    }\n\n    server {\n        listen       443 ssl;\n        server_name  developer.tidb.io;\n        root         /usr/share/nginx/html/dev-group;\n\n        ssl_certificate \"******\";\n        ssl_certificate_key \"******\";\n        (more ssl config ...)\n\n        # Load configuration files for the default server block.\n        include /etc/nginx/default.d/*.conf;\n\n        location / {\n        }\n    }\n\n实际配置以生产环境服务器中的配置文件为准\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingcap%2Fcommunity-website","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingcap%2Fcommunity-website","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingcap%2Fcommunity-website/lists"}