Skip to content

Commit

Permalink
docs: make site build (#5446)
Browse files Browse the repository at this point in the history
* chore: make site build

* docs: make api reference work

* chore: add case gallery

* docs: add one demo
  • Loading branch information
hustcc authored Feb 20, 2024
1 parent 095581a commit a4a2299
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 143 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"prepare": "husky install",
"build": "run-s build:*",
"build:g6": "cd ./packages/g6 && npm run build",
"build:map-view": "cd ./packages/g6-plugin-map-view && npm run build",
"build:react-node": "cd ./packages/react-node && npm run build",
"build:map-view": "cd ./packages/g6-plugin-map-view",
"build:react-node": "cd ./packages/react-node",
"build:site": "cd ./packages/site && npm run build",
"ci:g6": "cd ./packages/g6 && npm run ci",
"ci": "run-s ci:*"
Expand Down
9 changes: 4 additions & 5 deletions packages/site/.dumi/global.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// @ts-nocheck

if (window) {
// window.g6 = require('@antv/g6/es'); // import the source for debugging
window.g6 = require('@antv/g6/lib'); // import the source for debugging
window.g6 = require('@antv/g6'); // import the source for debugging

window.layoutGpu = require('@antv/layout-gpu'); // import the source for debugging
window.algorithm = require('@antv/algorithm');
window.layoutWasm = require('@antv/layout-wasm'); // import the source for debugging
window.graphlib = require('@antv/graphlib');

window.g6PluginMapView = require('@antv/g6-plugin-map-view');
// window.g6 = require('@antv/g6/diFst/g6.min.js'); // import the package for webworker
// todo 两个包目前报错
// window.g6PluginMapView = require('@antv/g6-plugin-map-view');
// window.g6ReactNode = require('@antv/g6-react-node');
window.insertCss = require('insert-css');
window.util = require('@antv/util');
window.stats = require('stats.js');
Expand All @@ -19,5 +19,4 @@ if (window) {

window.React = require('react');
window.ReactDOM = require('react-dom');
window.g6ReactNode = require('@antv/g6-react-node');
}
18 changes: 17 additions & 1 deletion packages/site/.dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ export default defineConfig({
// 头部的菜单中的「周边生态」
],
docs: [
{
slug: 'manual/v5',
title: {
zh: '🎉 新版本 5.0',
en: '🎉 New v5.0',
},
order: 4,
},
{
slug: 'manual/tutorial',
title: {
Expand Down Expand Up @@ -125,7 +133,7 @@ export default defineConfig({
{
slug: 'apis/reference',
title: {
zh: 'API Reference',
zh: 'API 文档',
en: 'API Reference',
},
order: 1,
Expand Down Expand Up @@ -229,6 +237,14 @@ export default defineConfig({
en: '5.0 Features',
},
},
{
slug: 'case',
icon: 'gallery',
title: {
zh: '场景案例',
en: 'Case',
},
},
{
slug: 'net',
icon: 'net',
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 🎉 Beta Published
title: Beta Published
order: 2
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 🎉 Beta 发布稿
title: Beta 发布稿
order: 2
---

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions packages/site/examples/feature/features/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Pz31S5UcA8AAAAAAAAAAAAAADmJ7AQ/original"
},
{
"filename": "mapView.js",
"title": {
"zh": "地图视图",
"en": "Map View"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*uQ_4R60w8sgAAAAAAAAAAAAADmJ7AQ/original"
},
{
"filename": "lodLevels.js",
"title": {
Expand Down
8 changes: 0 additions & 8 deletions packages/site/examples/item/customNode/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*GVyoQKk2WIIAAAAAAAAAAAAADmJ7AQ/original"
},
{
"filename": "jsx-g-node.js",
"title": {
"zh": "使用 JSX 写法创建自定义 G 节点",
"en": "JSX G Node"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*nFzoQ7qBLvEAAAAAAAAAAAAADmJ7AQ/original"
},
{
"filename": "react-node.js",
"title": {
Expand Down
167 changes: 52 additions & 115 deletions packages/site/examples/item/defaultNodes/demo/circle.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,70 @@
import { Graph } from '@antv/g6';

const Icons = [
'https://gw.alipayobjects.com/zos/rmsportal/eOYRaLPOmkieVvjyjTzM.png',
'https://gw.alipayobjects.com/zos/rmsportal/dWJWRLWfpOEbwCyxmZwu.png',
'https://gw.alipayobjects.com/zos/rmsportal/ZEPeDluKmAoTioCABBTc.png',
'https://gw.alipayobjects.com/zos/rmsportal/eZYhlLzqWLAYwOHQAXmc.png',
'https://gw.alipayobjects.com/zos/rmsportal/vXiGOWCGZNKuVVpVYQAw.png',
'https://gw.alipayobjects.com/zos/rmsportal/NjApYXminrnhBgOXyuaK.png',
];

const data = {
nodes: [
{
id: 'circle',
data: {},
},
{
id: 'circle-active',
data: {},
},
{
id: 'circle-selected',
data: {},
},

{
id: 'circle-highlight',
data: {},
},
{
id: 'circle-inactive',
data: {},
},
{
id: 'circle-badges',
data: {},
},
{
id: 'circle-anchorShapes',
data: {},
},
{ id: 'circle' },
{ id: 'circle-halo' },
{ id: 'circle-badges' },
{ id: 'circle-ports' },
{ id: 'circle-active' },
{ id: 'circle-selected' },
{ id: 'circle-highlight' },
{ id: 'circle-inactive' },
],
};

const container = document.getElementById('container');
const width = container.scrollWidth;
const height = container.scrollHeight || 500;
const graph = new Graph({
container: 'container',
width,
height,
modes: {
default: ['zoom-canvas', 'drag-canvas', 'drag-node', 'click-select'],
},
plugins: [
{
// lod-controller will be automatically assigned to graph with `disableLod: false` to graph if it is not configured as following
type: 'lod-controller',
disableLod: true,
},
],
width: 600,
height: 400,
theme: 'light',
data,
layout: {
type: 'grid',
},
node: (model) => {
const { id, data } = model;
const config = {
id,
data: {
...data,
type: 'circle-node',
labelShape: {
text: id,
position: 'bottom',
maxWidth: '500%',
},
labelBackgroundShape: {},
iconShape: {
img: 'https://gw.alipayobjects.com/zos/basement_prod/012bcf4f-423b-4922-8c24-32a89f8c41ce.svg',
},
animates: {
update: [
{
fields: ['opacity'],
shapeId: 'haloShape',
states: ['selected', 'active'],
},
{
fields: ['lineWidth'],
shapeId: 'keyShape',
states: ['selected', 'active'],
},
],
},
node: {
style: {
type: 'circle',
r: 20,
labelText: (d) => d.id,
iconSrc: (_, idx) => Icons[idx % Icons.length],
halo: (d) => d.id.includes('halo'),
},
state: {
active: {
halo: true,
},
};
if (id.includes('badges')) {
config.data.badgeShapes = [
{
text: 'A',
position: 'rightTop',
},
{
text: 'Important',
position: 'right',
},
{
text: 'Notice',
position: 'rightBottom',
},
];
}
if (id.includes('anchorShapes')) {
config.data.anchorShapes = [
{
position: [0, 0.5],
},
{
position: [0.5, 0],
},
{
position: [0.5, 1],
},
{
position: [1, 0.5],
},
];
selected: {
halo: true,
lineWidth: 2,
stroke: '#000',
},
highlight: {
halo: false,
lineWidth: 2,
stroke: '#000',
},
inactive: {
opacity: 0.2,
}
}
return config;
},
}
});

graph.on('afterrender', (e) => {
graph.setItemState('circle-active', 'active', true);
graph.setItemState('circle-selected', 'selected', true);
graph.setItemState('circle-highlight', 'highlight', true);
graph.setItemState('circle-inactive', 'inactive', true);
});
graph.render();

window.graph = graph;
graph.on('afterrender', () => {
graph.setElementState('circle-active', 'active');
graph.setElementState('circle-selected', 'selected');
graph.setElementState('circle-highlight', 'highlight');
graph.setElementState('circle-inactive', 'inactive');
});
2 changes: 1 addition & 1 deletion packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"build": "npm run doc && dumi build",
"deploy": "npm run build && gh-pages -d dist",
"develop": "dumi dev",
"dev": "dumi dev",
"doc": "npm run doc:prepare && ts-node ./scripts/generate-api.ts && ts-node ./scripts/generate-intl.ts",
"doc:prepare": "node ./scripts/env-setup.cjs USE_TS_NODE true",
"find-unused-demos": "node ./scripts/find-unused-demos.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/site/scripts/generate-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function mangleScopedPackageName(packageName: string): string {

const reportFolderRoot = path.resolve(__dirname, '..', path.join('support', 'api'));
const reportTempFolderRoot = path.resolve(reportFolderRoot, 'temp');
const ignorePackages = new Set<string>(['@antv/g6-react-node']);
const ignorePackages = new Set<string>(['@antv/g6-react-node', '@antv/g6-plugin-map-view', '@antv/g6-site']);

/**
* Get all typed packages.
Expand Down

0 comments on commit a4a2299

Please sign in to comment.