Skip to content

Commit 0f4cae4

Browse files
ffff
authored andcommitted
fix: 修复关于uiw底部foote不显示
1 parent cfd9ea3 commit 0f4cae4

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

website/src/component/Markdown/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default class Markdown extends Component<MarkdownProps, MarkdownState> {
8282
</div>
8383
);
8484
}
85+
8586
return (
8687
<Fragment>
8788
<div className={styles.warpper} style={style}>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Divider } from 'uiw';
2+
3+
export default function (props) {
4+
const { path } = props;
5+
const url = /^http/.test(path || '') ? path : `https://github.com/uiwjs/react-native-uiw/edit/master/${path}`;
6+
return (
7+
<div style={{ paddingBlock: 20 }}>
8+
{url && (
9+
<a href={url} target="_blank" rel="noopener noreferrer">
10+
在Github上编辑本页!
11+
</a>
12+
)}
13+
<Divider type="vertical" />
14+
<a target="_blank" rel="noopener noreferrer" href="https://github.com/uiwjs/react-native-uiw/issues">
15+
提交bug
16+
</a>
17+
</div>
18+
);
19+
}

website/src/component/Preview/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BackTop, Circle, Icon } from 'uiw';
44
import { getMetaId, isMeta, getURLParameters } from 'markdown-react-code-preview-loader';
55
import CodeLayout from 'react-code-preview-layout';
66
import { useRef } from 'react';
7+
import Footer from './Footer';
78

89
const Wrapper = styled.div`
910
width: 100%;
@@ -14,6 +15,8 @@ const Wrapper = styled.div`
1415
}
1516
display: flex;
1617
justify-content: center;
18+
align-items: center;
19+
flex-direction: column;
1720
`;
1821

1922
const Markdown = styled(MarkdownPreview)`
@@ -34,9 +37,8 @@ const getBooleanValue = (param, field, defaultValue) => {
3437
return defaultValue;
3538
};
3639

37-
const Preview = (mdData) => {
40+
const Preview = ({ path, ...mdData }) => {
3841
const $dom = useRef(null);
39-
4042
return (
4143
<Wrapper ref={$dom}>
4244
<Markdown
@@ -85,6 +87,7 @@ const Preview = (mdData) => {
8587
},
8688
}}
8789
/>
90+
<Footer path={path} />
8891
<BackTop speed={500}>
8992
{({ percent, scrollToTop }) => (
9093
<Circle
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Preview from 'src/component/Preview';
22
import md from '@uiw/react-native/README.md';
33

4-
const Demo = () => <Preview {...md} />;
4+
const Demo = () => <Preview {...md} path="/packages/core/README.md" />;
55

66
export default Demo;

website/src/pages/docs/development/document/README.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,27 @@ export const getRouterData = {
162162
添加 `website/src/pages/docs/getting-started/README.md``website/src/pages/docs/getting-started/index.tsx`
163163

164164
```tsx
165-
import Markdown, { importAll } from '../../../component/Markdown';
166-
167-
export default class Page extends Markdown {
168-
// 配置 markdown 在 GitHub 中的目录位置,用于定位编辑 Markdown
169-
path = "/website/src/pages/docs/getting-started/README.md";
170-
getMarkdown = async () => {
171-
// 这里加载指定的 Markdown 文件
172-
const md = await import('./README.md');
173-
// 也可加载组件包中的文档
174-
const mdCom = await import('@uiw/react-native/lib/Badge/README.md');
175-
// 支持 markdown 中,相对于当前 index.tsx 相对路径引入图片资源
176-
importAll((require as any).context('./', true, /\.(png|gif|jpg|svg)$/), this.imageFiles);
177-
return md.default || md;
178-
}
165+
import Preview from 'src/component/Preview';
166+
import md from './README.md';
167+
168+
const DEMO = () => <Preview {...md} />;
169+
export default DEMO;
170+
171+
```
172+
> 注意: 如果markdown有本地图片需要增加transformImageUri配置,否则不现实图片
173+
```tsx
174+
import Preview from 'src/component/Preview';
175+
import md from './README.md';
176+
177+
const transformImageUri = (url: string) => {
178+
const reqImage = (require as any).context('./', true, /\.(png|gif|jpg|svg)$/)
179+
const urlAddr = reqImage(url)
180+
return urlAddr
179181
}
182+
183+
const DEMO = () => <Preview {...md} transformImageUri={transformImageUri} />;
184+
export default DEMO;
185+
180186
```
181187

182188
### `修改一个 Markdown 文件内容`

0 commit comments

Comments
 (0)