Skip to content

Commit

Permalink
chore: use dumi (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg authored Apr 14, 2021
1 parent 709a6c7 commit 9e0c47f
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ yarn.lock
package-lock.json
coverage/
.doc
tsconfig.json
# umi
.umi
.umi-production
.umi-test
.env.local
4 changes: 4 additions & 0 deletions .umirc.gh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
base: '/resize-observer/',
publicPath: '/resize-observer/',
};
21 changes: 21 additions & 0 deletions .umirc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from 'dumi';

export default defineConfig({
title: 'rc-resize-observer',
favicon:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
logo:
'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
exportStatic: {},
outputPath: '.doc',
resolve: {
examples: ['none'],
},
styles: [
`
.markdown table {
width: auto !important;
}
`,
]
});
2 changes: 2 additions & 0 deletions HISTORY.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Changelog

## 0.5.0

- support `theme="dark|light"`.
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# rc-resize-observer

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Codecov][codecov-image]][codecov-url]
[![david deps][david-image]][david-url]
[![david devDeps][david-dev-image]][david-dev-url]
[![npm download][download-image]][download-url]
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][travis-image]][travis-url] [![Codecov][codecov-image]][codecov-url] [![david deps][david-image]][david-url] [![david devDeps][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url]

[npm-image]: http://img.shields.io/npm/v/rc-resize-observer.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-resize-observer
Expand Down
3 changes: 3 additions & 0 deletions docs/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## basic

<code src="../../examples/basic.tsx">
3 changes: 3 additions & 0 deletions docs/demo/debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## debug

<code src="../../examples/debug.tsx">
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: rc-resize-observer
---

<embed src="../README.md"></embed>
1 change: 0 additions & 1 deletion index.js

This file was deleted.

3 changes: 3 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"use": "@now/static-build",
"config": { "distDir": ".doc" }
}
],
"routes": [
{ "src": "/(.*)", "dest": "/dist/$1" }
]
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
},
"license": "MIT",
"scripts": {
"start": "cross-env NODE_ENV=development father doc dev --storybook",
"build": "father doc build --storybook",
"start": "dumi dev",
"build": "dumi build",
"compile": "father build && lessc assets/index.less assets/index.css",
"gh-pages": "npm run build && father doc deploy",
"deploy": "UMI_ENV=gh npm run build && gh-pages -d .doc",
"gh-pages": "npm run deploy",
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
"postpublish": "npm run gh-pages",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
Expand All @@ -53,10 +54,13 @@
"@umijs/fabric": "^2.0.9",
"coveralls": "^3.0.6",
"cross-env": "^7.0.2",
"dumi": "^1.1.12",
"enzyme": "^3.0.0",
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.4.0",
"father": "^2.13.4",
"gh-pages": "^3.1.0",
"glob": "^7.1.6",
"less": "^3.10.3",
"np": "^6.2.4",
"prettier": "^2.1.1",
Expand Down
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"jsx": "preserve",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"],
"rc-resize-observer": ["src/index.tsx"]
}
}
}
29 changes: 29 additions & 0 deletions update-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
用于 dumi 改造使用,
可用于将 examples 的文件批量修改为 demo 引入形式,
其他项目根据具体情况使用。
*/

const fs = require('fs');
const glob = require('glob');

const paths = glob.sync('./examples/*.tsx');

paths.forEach(path => {
const name = path.split('/').pop().split('.')[0];
fs.writeFile(
`./docs/demo/${name}.md`,
`## ${name}
<code src="../../examples/${name}.tsx">
`,
'utf8',
function(error) {
if(error){
console.log(error);
return false;
}
console.log(`${name} 更新成功~`);
}
)
});

0 comments on commit 9e0c47f

Please sign in to comment.