You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReactfrom'react';import{useTranslation}from'react-i18next';constIndepent=()=>{const{ t }=useTranslation();return<>{t('独立页面')}</>;};Indepent.noLayout=true;exportdefaultIndepent;
Activity
afc163 commentedon Nov 1, 2019
✨ 子站点改造开始了!
目前 gatsby-theme-antv 的基础功能已经就绪,细节功能还在补充,下周开始做视觉还原,各个子站点今天开始已经进行接入了:
接入方式
这里写一个简单的接入步骤,完整请参考 https://github.com/antvis/gatsby-theme-antv 的 README 和下列示例网站进行接入:
安装依赖
添加
gatsby-config.js和gatsby-browser.js文件两个文件的内容参考:
GATrackingId 的配置请联系偏右,我去 GA 后台生成一个。
(可选)添加 babel-preset-gatsby
如果你的项目有
.babelrc文件,需要加入相关的 preset修改
.babelrc,确保放在presets的最后。{ "presets": [ ... + "babel-preset-gatsby" ] }可以参考:https://github.com/antvis/g2/pull/1605/files
忽略临时发布目录
public和.cache是 gatsby 生成的静态文件目录和临时目录,不需要提交,将它们加到.gitignore目录里。添加相关的 scripts 命令
https://github.com/antvis/g2plot/blob/97fb088e03ab9561d2377386877b071ba509cec1/package.json#L22-L26
"scripts": { ... + "start": "npm run site:develop", + "site:develop": "gatsby develop --open -H 0.0.0.0", + "site:build": "npm run site:clean && gatsby build --prefix-paths", + "site:clean": "gatsby clean", + "site:deploy": "npm run site:build && gh-pages -d public", ... }然后运行
npm start尝试一下,访问 https://127.0.0.1:8000 即可看到页面效果。创建首页
site/pages目录site/pages/index.zh.ts和site/pages/index.en.ts分别对应中英文首页。site/locale.json统一存放国际化配置。内容参考 https://github.com/antvis/g2plot/blob/master/site/
将文档迁移到 docs 目录下
所有 md 文件需要用下列格式定义相关属性。
可以用
redirect_from字段来定义顶部导航的默认文档。比如下面所有zh/docs/manual的链接(通常放在顶部导航)会跳转到下面这个文档上。注意,需要同时提供中英文两个版本的文档文件,暂时没翻译就复制一份中文文档即可。
将演示迁移到 examples 目录下
参考 https://github.com/antvis/g2plot/blob/master/examples/
examples/data下,使用时遇到 404 需要注意相对路径问题:https://github.com/antvis/g2plot/pull/177。当然也可以传到 basement cdn 上用绝对地址来调用。import g2plot from '@antv/g2plot';slug为examples得这一项即可,examples字段也可以删掉。自定义顶部菜单
gatsby-config.js的navs字段里可以定义修改菜单。target: '_blank'可以新窗口打开。自定义页面
site/pages里创建文件即可,custom.zh.js对应/zh/customcustom.en.js对应/en/custom。noLayout = true:国际化文案配置
使用 react-i18next 作为内建的国际化方案,使用时只需要
const { t, i18n } = useTranslation();即可。API 参考 react-i18next 官方文档使用。国际化文案的键值对统一放在项目下的site/locale.json内,以中文作为 key,英文作为翻译内容。antvis.github.io/site/pages/index.zh.tsx
Line 13 in 3296c99
使用图片
basement cdnsrc/images目录下:antvis.github.io/site/pages/index.zh.tsx
Line 5 in 3296c99
开启 gh-pages 服务
npm run site:deploy之后会部署到gh-pages分支上,访问路径为:https://antvis.github.io/xxx(可选)开启 netlify 预览服务
npm run site:buildpublic设置环境变量不需要了GATSBY_PATH_PREFIX为/以保证根域名的预览。开启之后 PR 会有预览的地址:antvis/G#234 (comment)
注意⚠️ ⚠️ ⚠️
首页可以等等,我们会提一些通用的 Banner、Features 组件方便大家统一开发。十吾开发好了组件了,可以开始了!https://github.com/antvis/gatsby-theme-antv#componentsnavsexamplesdocs的具体配置参考:https://github.com/antvis/gatsby-theme-antv#usage时间点
11-09之前所有的 antvis.github.io/xxx 页面要能访问,文档和演示能用。pomelo-nwu commentedon Nov 6, 2019
@afc163 偏右老师,Graphin站点已经接入:https://antvis.github.io/graphin/
文档明天开始准备,陆续更新。
afc163 commentedon Nov 6, 2019
pomelo-nwu commentedon Nov 7, 2019
@afc163 好的~
afc163 commentedon Nov 9, 2019
旧版本网站地址收集,新网站上线后做一个跳转。
anyexinglu commentedon Nov 27, 2019
请问一下,为啥迁移站点,感觉之前挺好的了,gatsby主题会带来额外增益么?
afc163 commentedon Dec 24, 2019
补充一些后面添加的功能: