Skip to content

Commit edf5579

Browse files
committed
website: fix markdown preview type error.
1 parent 3940c51 commit edf5579

File tree

6 files changed

+32
-43
lines changed

6 files changed

+32
-43
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@
3636
]
3737
},
3838
"devDependencies": {
39-
"cross-env": "^7.0.3",
4039
"husky": "^8.0.0",
41-
"lerna": "^7.1.5",
42-
"lint-staged": "^14.0.1",
40+
"lerna": "^8.0.0",
41+
"lint-staged": "^15.1.0",
4342
"prettier": "^3.0.2",
4443
"tsbb": "^4.1.5"
4544
}

website/.kktrc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export default (conf: Configuration, env: 'production' | 'development', options:
1818
}),
1919
);
2020
conf.module!.exprContextCritical = false;
21+
conf.ignoreWarnings = [{ module: /node_modules[\\/]parse5[\\/]/ }];
22+
2123
if (env === 'production') {
2224
conf.optimization = {
2325
...conf.optimization,

website/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"map": "source-map-explorer build/static/js/*.js --html build/website-result.html"
1313
},
1414
"devDependencies": {
15-
"@kkt/less-modules": "^7.4.9",
16-
"@kkt/raw-modules": "^7.4.9",
17-
"@kkt/scope-plugin-options": "^7.4.9",
15+
"@kkt/less-modules": "^7.5.4",
16+
"@kkt/raw-modules": "^7.5.4",
17+
"@kkt/scope-plugin-options": "^7.5.4",
1818
"@types/katex": "^0.16.0",
1919
"@types/react": "~18.2.0",
2020
"@types/react-dom": "~18.2.0",
2121
"@types/react-test-renderer": "^18.0.2",
22-
"kkt": "^7.4.9",
22+
"kkt": "^7.5.4",
2323
"source-map-explorer": "~2.5.2"
2424
},
2525
"dependencies": {

website/src/comps/Nav.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const Menu = styled.nav`
2020
export const Nav = () => {
2121
return (
2222
<Menu>
23+
<a href="https://jaywcjlove.github.io/#/sponsor" target="_blank" rel="noreferrer">
24+
Sponsor
25+
</a>
2326
<NavLink to="/">Home</NavLink>
2427
<NavLink to="/docs">Document</NavLink>
2528
<a href="https://github.com/uiwjs/react-login-page" rel="noreferrer" target="_blank">

website/src/comps/Preview.tsx

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ const MarkdownCode = CodeLayout.Preview;
1515
const Code = CodeLayout.Code;
1616
const Toolbar = CodeLayout.Toolbar;
1717

18-
const Wrapper = styled.div<{ isShowExample?: boolean }>`
18+
const Wrapper = styled.div<{ $isShowExample?: boolean }>`
1919
flex: 1;
2020
padding-right: 0.51rem;
2121
padding-left: 0.51rem;
2222
overflow: hidden;
2323
z-index: 1;
24-
padding-top: ${({ isShowExample }) => (isShowExample ? '0' : '0')};
24+
padding-top: ${({ $isShowExample }) => ($isShowExample ? '0' : '0')};
2525
margin: 0 auto;
2626
width: 100%;
2727
${mediaStyle}
@@ -95,52 +95,34 @@ export const Preview: FC<PropsWithChildren<PreviewProps>> = (props) => {
9595
</PageArrow>
9696
</NavMenu>
9797
)}
98-
<Wrapper isShowExample={props.disableNav}>
98+
<Wrapper $isShowExample={props.disableNav}>
9999
{loading && <div>Loading...</div>}
100100
{mdData && !loading && (
101101
<Markdown
102102
source={mdData.source}
103103
rehypeRewrite={(node: Root | RootContent, index: number, parent: Root | Element) => {
104104
if (node.type === 'element' && parent && parent.type === 'root') {
105-
const menu = parent.children[1] as Element | undefined;
106-
let childLength = [...parent.children].filter((item) => item.type !== 'raw').length;
107-
const lastChild = parent.children[parent.children.length - 1];
108-
if (lastChild?.type === 'raw') {
109-
childLength = parent.children.length - 2;
110-
}
111-
if (
112-
(index + 1 === childLength || index - 1 === childLength || index === childLength) &&
113-
menu?.properties?.class !== 'menu-toc'
114-
) {
115-
const child = [...parent.children].map((item) => {
116-
if (item.type === 'element' && item.tagName === 'pre') {
117-
const meta = item.children[0]?.data?.meta as string;
118-
if (isMeta(meta)) {
119-
item.tagName = 'div';
120-
item.properties = {
121-
...item.properties,
122-
'data-md': meta,
123-
'data-meta': 'preview',
124-
};
125-
return { ...item };
126-
}
105+
[...parent.children].map((item) => {
106+
if (item.type === 'element' && item.tagName === 'pre') {
107+
const meta = (item.children[0]?.data as any)?.meta as string;
108+
if (isMeta(meta)) {
109+
item.tagName = 'div';
110+
item.properties = {
111+
...item.properties,
112+
'data-md': meta,
113+
'data-meta': 'preview',
114+
};
115+
return { ...item };
127116
}
128-
return item;
129-
});
130-
parent.children = [
131-
{
132-
type: 'element',
133-
tagName: 'div',
134-
children: child as Element[],
135-
},
136-
];
137-
}
117+
}
118+
return item;
119+
});
138120
}
139121
}}
140122
components={{
141123
div: ({ node, ...props }) => {
142124
const { 'data-meta': meta, 'data-md': metaData, ...rest } = props as any;
143-
const line = node.position?.start.line;
125+
const line = node?.position?.start.line;
144126
const metaId = getMetaId(metaData) || String(line);
145127
const Child = mdData.components[metaId];
146128
if (meta !== 'preview' || !metaId || typeof Child !== 'function') return <div {...props} />;

website/src/pages/home.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export const Home = () => {
8484
<a href="https://github.com/uiwjs/react-login-page" target="_blank" rel="noreferrer">
8585
Github
8686
</a>
87+
<a href="https://jaywcjlove.github.io/#/sponsor" target="_blank" rel="noreferrer">
88+
Sponsor
89+
</a>
8790
</Nav>
8891
<Example />
8992
</Wrapper>

0 commit comments

Comments
 (0)