GithubHelp home page GithubHelp logo

antvis / gatsby-theme-antv Goto Github PK

View Code? Open in Web Editor NEW
342.0 24.0 57.0 27.9 MB

⚛️ Polished Gatsby theme for documentation site

Home Page: https://gatsby-starter-theme-antv.antv.vision/zh

License: Other

JavaScript 9.33% TypeScript 69.82% Less 20.85%
antv gatsby-theme antvis react antd gatsbyjs gatsby gatsby-starter

gatsby-theme-antv's Introduction

图片

Gatsby Theme for AntV ⚛

✨ Polished Gatsby theme for documentation site.

NPM downloads CI status

Dependency Status

Features

  • ⚛ Prerendered static site
  • 🌎 Internationalization support by i18next
  • 📝 Markdown-based documentation and menus
  • 🎬 Examples with live playground
  • 🏗 Unified Theme and Layout
  • 🆙 Easy customized header nav
  • 🧩 Built-in home page components

Websites using it

Usage

Create a Gatsby site from gatsby-starter-theme-antv.

$ yarn global add gatsby-cli // or npm install gatsby-cli -g
$ gatsby new mysite https://github.com/antvis/gatsby-starter-theme-antv

Start developing.

$ cd mysite
$ yarn start

✨ AntV 站点 接入方式额外功能

gatsby-config.js

// gatsby-config.js
const { repository } = require('./package.json');

module.exports = {
  plugins: [
    {
      resolve: `@antv/gatsby-theme-antv`,
      options: {
        // pagesPath: './site/pages',
        GATrackingId: `UA-XXXXXXXXX-X`,
        pathPrefix: '/g2',
        // antd 主题:https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
        theme: {
          'primary-color': '#873bf4',
        },
        pwa: true, // 是否开启 gatsby-plugin-offline
        cname: true, // 是否自动从 siteUrl 中提取 CNAME 文件
        codeSplit: true, // 是否开启 gatsby 按路由的代码分割,默认为 false
      },
    },
  ],
  siteMetadata: {
    title: `AntV`,
    description: `Ant Visualization solution home page`,
    githubUrl: repository.url,
    logoUrl: '', // 自定义 logo
    navs: [], // 用于定义顶部菜单
    docs: [], // 用于定义文档页面的二级分类菜单
    examples: [], // 用于定义演示页面的二级菜单,属性见下方
    isAntVSite: false, //是否是AntV官网,header样式footer和图表详情页均为定制
    galleryMenuCloseAll: false, // 是否默认收起 gallery 页面所有 menu
    showSearch: true, // 是否展示搜索框
    docsearchOptions: { // algolia 搜索配置
      versionV3: false, // 目前有两个版本的 docsearch.js,V2.x 和 V3.x,此开关决定用哪一个版本的搜索框,根据申请到的参数版本决定,二者互不兼容,详情见 https://docsearch.algolia.com/
      appId: 'xxxx', // V3.x 版本 docsearch 需要appId, V2.x 版不需要。
      apiKey: 'xxxxxx',
      indexName: 'xxx',

    }
    showChinaMirror: true, // 是否展示国内镜像链接
    showLanguageSwitcher: true, // 用于定义是否展示语言切换
    showAntVProductsCard: true, // 是否展示 AntV 系列产品的卡片链接
    showGithubStar: false, // 是否展示 Github Star
    showGithubCorner: true, // 是否展示角落的 GitHub 图标
    showChartResize: true, // 是否在demo页展示图表视图切换
    themeSwitcher: 'g2', // 是否在demo页展示主题切换, 取值为'g2' | 'g2plot' 如果不设置则不展示主题切换工具
    showAPIDoc: true, // 是否在demo页展示API文档
    showExampleDemoTitle: true, // 有截图的是否要展示 title 名称

    mdPlayground: {
      // markdown 文档中的 playground 若干设置
      splitPaneMainSize: '62%',
    },
    playground: {
      container: '<canvas id="container" />', // 定义演示的渲染节点,默认 <div id="container" />
      playgroundDidMount: 'console.log("playgroundDidMount");',
      playgroundWillUnmount: 'console.log("playgroundWillUnmount");',
      devDependencies: {
        // 如果 example 是 ts 文件,需要加上 ts 依赖,才能在 codesandbox 正确运行
        typescript: 'latest',
      },
    },
    versions: [
      {
        '1.x': 'https://1x.ant.design',
        '2.x': 'https://2x.ant.design',
        '3.x': 'https://ant.design',
        '4.x': 'https://next.ant.design',
      },
    ],
    redirects: [
      {
        from: /\/old-url/,
        to: '/new-url', // 不指定 to 时直接跳转到 https://antv-2018.alipay.com/***
      },
    ],
    announcement: {
      zh: '站内公告,用于展示一些更新信息,如:文档更新、版本发布等',
      en:
        'The announcement in the website, used to display some updated information, such as document update, version release and etc',
    },
  },
};

Components

import SEO from '@antv/gatsby-theme-antv/site/components/Seo';
import Header from '@antv/gatsby-theme-antv/site/components/Header';
import Footer from '@antv/gatsby-theme-antv/site/components/Footer';
import Banner from '@antv/gatsby-theme-antv/site/components/Banner';
import Features from '@antv/gatsby-theme-antv/site/components/Features';
import Applications from '@antv/gatsby-theme-antv/site/components/Applications';
import Companies from '@antv/gatsby-theme-antv/site/components/Companies';

// @antv/gatsby-theme-antv/components/Header for commonjs version

const Layout = () => {
  const features = [
    {
      icon: 'https://gw.alipayobjects.com/zos/basement_prod/5dbaf094-c064-4a0d-9968-76020b9f1510.svg',
      title: 'xxxxx',
      description: 'xxxxxxxxxxxxxxxxxxxxxxxxx',
    },
    {
      icon: 'https://gw.alipayobjects.com/zos/basement_prod/0a0371ab-6bed-41ad-a99b-87a5044ba11b.svg',
      title: 'xxxxx',
      description: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    },
    {
      icon: 'https://gw.alipayobjects.com/zos/basement_prod/716d0bc0-e311-4b28-b79f-afdd16e8148e.svg',
      title: 'xxxxx',
      description: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    },
  ];
  const cases = [
    {
      logo: 'https://gw.alipayobjects.com/mdn/rms_23b644/afts/img/A*2Ij9T76DyCcAAAAAAAAAAABkARQnAQ',
      title: '灯塔专业版',
      description:
        '深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金深入金融的基金',
      link: '#',
      image:
        'https://gw.alipayobjects.com/mdn/rms_23b644/afts/img/A*oCd7Sq3N-QEAAAAAAAAAAABkARQnAQ',
    },
    // ...
  ];
  const companies = [
    {
      name: '公司1',
      image:
        'https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*Z1NnQ6L4xCIAAAAAAAAAAABkARQnAQ',
    },
    {
      name: '公司2',
      image:
        'https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*6u3hTpsd7h8AAAAAAAAAAABkARQnAQ',
    },
    // ...
  ];
  const notifications = [
    {
      type: '测试',
      title: 'G6 3.2 全新上线!',
      date: '2019.12.04',
      link: '#',
    },
  ];

  const downloadButton = {
    text: '下载使用',
    link: 'https://antv.alipay.com/zh-cn/index.html',
  };

  return (
    <>
      <SEO title="蚂蚁数据可视化" lang="zh" />
      <Header
        subTitle="子产品名"
        logo={{
          link: 'https://antv.alipay.com',
          img: <img src="url" />,
        }}
        githubUrl="https://github.com/antvis/g2"
        // docs={[]}
        showSearch={false}
        showGithubCorner={false}
        showLanguageSwitcher={false}
        onLanguageChange={(language) => {
          console.log(language);
        }}
        defaultLanguage="zh"
      />
      <Footer
      // columns={[]}
      // bottom={<div>powered by antv</div>}
      />

      <Banner
        coverImage={<svg></svg>} // 右侧 banner svg 内容
        title="主页标题"
        description="主页描述内容描述内容描述内容描述内容"
        buttonText="按钮文字"
        buttonHref={'#按钮链接路径'}
        notifications={notifications} // 可传 1-2 个内容,若不传则显示 2 个默认通知
        style={{}}
        className="Banner 的 className"
        video="视频按钮点开后视频的链接,不传则不会出现视频按钮"
        githubStarLink="Github Star 链接,不传则不会出现 GitHub Start 按钮"
        downloadButton={downloadButton} // 不传则不会出现下载按钮
      />
      <Features
        title="优势页面名称" // 可不传
        features={features} // 必传
        style={{}}
        className="Features 的 className"
      />
      <Cases cases={cases} style={{}} className="Cases 的 className" />
      <Companies
        title="公司页面名称" // 必传
        companies={companies} // 必传
        style={{}}
        className="Companies 的 className"
      />
    </>
  );
};

Custom Tag in Markdown

We support three type of custom tags in markdown

  • tag
<tag color="green" text="分类图例">分类图例</tag>

See antd Tag components for more usage.

  • swatch
<swatch colors="#F4664A,#30BF78,#FAAD14" colorNames="Red,Green,Yellow"></swatch>

swatch props:

name description isRequired type default
title - true string -
darkmode - false boolean -
colors - false string -
colornames - false string -
grid - false 'sudoku' 'sudoku'
  • playground

Insert demos to markdown document as code playground.

将 demo 以代码预览效果插入到 markdown 文档中。

<playground path='category/basic/demo/ts-demo.ts' rid='container'></playground>

playground props:

name description isRequired type default
path demo relative path true string -
height height of code playground false number 400
rid specify the container ID when more than one demo in docs false string 'container'

Develop

yarn install
yarn start

Visit https://localhost:8000 to preview.

Publish to npm

⚠️ If it is your first time for GitHub release, please read the following steps, otherwise, you can skip directly to the third step.

  1. Generate a personal access token: (release-it only needs "repo" access; no "admin" or other scopes).

generate token

Click the button 'Generate token', then your token would be generated. Copy this token as soon as you get it since you won’t be able to see it again after refreshing the web page!

  1. Make sure the token is available as an environment variable.

Example:

export GITHUB_TOKEN="YOUR TOKEN"

In macOS or Linux, this can be added to e.g. ~/.profile or ~/.zshrc, so it's available everytime the shell is used.

More details for the GitHub releases preperation: GitHub Releases

  1. Run the following commands in your terminal.
cd @antv/gatsby-theme-antv
npm run release

Deploy

npm run deploy

Set envoironment variable GATSBY_PATH_PREFIX to / in deploy service like netlify to preview pathPrefix site in root domain.

Add Dependency

cd @antv/gatsby-theme-antv
yarn add shallowequal

or

yarn workspace @antv/gatsby-theme-antv add shallowequal

Q&A

How to customise layout footer?

// gatsby-browser.js
exports.wrapPageElement = ({ element, props }) => {
  return React.cloneElement(element, {
    ...props,
    ...element.props,
    // https://github.com/react-component/footer#api
    footerProps: {
      bottom: 'xxx',
    },
  });
};

How to embed other markdown document in a markdown document

`markdown:docs/common/data-mapping.zh.md`

docs/common/data-mapping.zh.md is the path relative to the current project. It supports multiple levels of nested.

Related libraries

gatsby-theme-antv's People

Contributors

afc163 avatar ai-qing-hai avatar bbsqq avatar bubkoo avatar csjkevin avatar curly210102 avatar dependabot-preview[bot] avatar eve-sama avatar hustcc avatar imgbot[bot] avatar imgbotapp avatar jeffy2012 avatar lxfu1 avatar newbyvector avatar october-rain avatar peachscript avatar simaq avatar susiwen8 avatar tonywu6 avatar visiky avatar xingwanying avatar xrkffgg avatar yanyan-wang avatar zengyue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gatsby-theme-antv's Issues

带有中划线(-)的包名,挂载到 window 对象后无法 import

  • 对于 G 来说,现在是两个独立的包名,@antv/g-canvas@antv/g-svg。在 gatsby-config.js 中按照以下配置:
window['g-canvas'] = require('./packages/g-canvas/src/index.ts');
// or
window['@antv/g-canvas'] = require('./packages/g-canvas/src/index.ts');
  • demo 代码中都无法 import:
import { Canvas } from '@antv/g-canvas'; 

image

  • 包名换成 g 或者 g_canvas 都是可以正确 import 的,但中划线分隔的包名就报错。

image

Banner组件button type及Icon组件部分style样式没有主题配置关联

业务层自定义site/index.zh.tsx,遇到的issue:

https://github.com/antvis/gatsby-theme-antv/blob/master/%40antv/gatsby-theme-antv/site/components/Banner.tsx

  1. ButtonLink组件目前只支持primary和非primary,buttons map 的array没有render antd button组件,所以在业务方配置bannerButtons时(比如指定别的type:warning) 此处button视觉不生效,建议可以内嵌antd button,便于配置和props共享。

image
image

  1. 第141行 Icon组件的props style 没必要传写死的color属性了 便于走主题配置

image

PS. 本来想给学长提PR的 权限摸索中~ 😄

启动网站 build 报错

@antv/gatsby-theme-antv 试了 0.10.45、0.10.46、0.10.49,本地启动网站 build 时都会报下面这个问题:
image

windows系统下 图表演示页面无法打开,控制台报错。

image

同事在windows下的ubuntu下打开是正常显示的,windows则不可。

报错文本信息如下:
Uncaught TypeError: Cannot read property 'relativePath' of undefined
at PlayGrounds (PlayGrounds.tsx:139)
at renderWithHooks (react-dom.development.js:16240)
at mountIndeterminateComponent (react-dom.development.js:18774)
at beginWork$1 (react-dom.development.js:20136)
at HTMLUnknownElement.callCallback (react-dom.development.js:337)
at Object.invokeGuardedCallbackDev (react-dom.development.js:386)
at invokeGuardedCallback (react-dom.development.js:441)
at beginWork$$1 (react-dom.development.js:25737)
at performUnitOfWork (react-dom.development.js:24661)
at workLoopSync (react-dom.development.js:24637)
at performSyncWorkOnRoot (react-dom.development.js:24236)
at react-dom.development.js:12181
at unstable_runWithPriority (scheduler.development.js:818)
at runWithPriority$2 (react-dom.development.js:12131)
at flushSyncCallbackQueueImpl (react-dom.development.js:12176)
at flushSyncCallbackQueue (react-dom.development.js:12164)
at scheduleUpdateOnFiber (react-dom.development.js:23675)
at Object.enqueueSetState (react-dom.development.js:13976)
at LocationProvider../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:325)
at index.js:104

G2 升级至 0.9.34 后的一些反馈

  • 首页头部的连接被遮挡导致不可点击

image

  • 文档页面前部出现了未知的空白

2019-11-09 21-30-24 2019-11-09 21_31_31

  • 需求:G2 设计师完白大爷的设计稿里要求加一个继续下载按钮

Snip20191109_5

  • README 连接部分 404
    Snip20191109_6

  • 国际化方案没有生效捏...

image

添加 gitee 同步的 GitHub Action

以后不需要手动同步 Gitee 国内镜像仓库了,GitHub 提交后会自定同步。


make primary color consistent

I figured out someplace still use default color but primary color, it's better to make them consistent, what do you think?

background: linear-gradient(145deg, #c65aff, #248dff);

background: linear-gradient(130deg, #aa6aff 40%, #706dff);

I would do a PR using fade() as other place if you think so.

源码问题

请问@antv/gatsby-theme-antv 这部分代码怎么运行起来?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.