2023-07-20 19:27:33 +08:00
|
|
|
import { createStyles } from 'antd-style';
|
2023-02-03 13:39:46 +08:00
|
|
|
import { FormattedMessage, useRouteMeta } from 'dumi';
|
|
|
|
import type { PropsWithChildren } from 'react';
|
|
|
|
import React from 'react';
|
2023-07-28 16:17:43 +08:00
|
|
|
import { ConfigProvider, Layout, Typography } from 'antd';
|
2022-11-09 12:28:04 +08:00
|
|
|
import CommonHelmet from '../../common/CommonHelmet';
|
2023-02-03 13:39:46 +08:00
|
|
|
import EditButton from '../../common/EditButton';
|
|
|
|
import Footer from '../../slots/Footer';
|
|
|
|
import AffixTabs from './AffixTabs';
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
export type ResourceLayoutProps = PropsWithChildren<{}>;
|
|
|
|
|
2023-02-03 13:39:46 +08:00
|
|
|
const resourcePadding = 40;
|
|
|
|
const articleMaxWidth = 1208;
|
|
|
|
const resourcePaddingXS = 24;
|
|
|
|
|
2023-07-20 19:27:33 +08:00
|
|
|
const useStyle = createStyles(({ token, css }) => {
|
2022-11-09 12:28:04 +08:00
|
|
|
const { antCls } = token;
|
|
|
|
return {
|
|
|
|
resourcePage: css`
|
|
|
|
footer {
|
|
|
|
margin-top: 176px;
|
|
|
|
|
|
|
|
.rc-footer-container {
|
|
|
|
max-width: ${articleMaxWidth}px;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding-right: 0;
|
|
|
|
padding-left: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
resourceContent: css`
|
|
|
|
padding: 0 ${resourcePadding}px;
|
|
|
|
max-width: ${articleMaxWidth}px;
|
|
|
|
margin: 0 auto;
|
|
|
|
box-sizing: content-box;
|
2023-07-25 15:15:42 +08:00
|
|
|
min-height: 100vh;
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
|
|
> .markdown {
|
|
|
|
> p {
|
|
|
|
margin-bottom: 56px;
|
|
|
|
}
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
margin-top: 124px;
|
|
|
|
color: #314659;
|
|
|
|
font-weight: lighter;
|
|
|
|
font-size: 30px;
|
|
|
|
line-height: 38px;
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
margin-top: 88px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
margin-top: 56px;
|
|
|
|
font-weight: 400;
|
|
|
|
font-size: 24px;
|
|
|
|
line-height: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
p {
|
|
|
|
color: #697b8c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and (max-width: 767.99px) {
|
|
|
|
& {
|
|
|
|
article {
|
|
|
|
padding: 0 ${resourcePaddingXS}px;
|
|
|
|
}
|
|
|
|
|
|
|
|
${antCls}-col {
|
|
|
|
padding-top: 16px !important;
|
|
|
|
padding-bottom: 16px !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
banner: css`
|
|
|
|
padding: 0 ${resourcePadding}px;
|
|
|
|
overflow: hidden;
|
|
|
|
background: url('https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*y_r7RogIG1wAAAAAAAAAAABkARQnAQ');
|
|
|
|
background-size: cover;
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
box-sizing: content-box;
|
|
|
|
max-width: ${articleMaxWidth}px;
|
|
|
|
margin: 56px auto 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
section {
|
|
|
|
max-width: ${articleMaxWidth}px;
|
|
|
|
margin: 0 auto 56px;
|
|
|
|
font-weight: 200;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 24px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and (max-width: 767.99px) {
|
|
|
|
& {
|
|
|
|
margin: 0 -${resourcePaddingXS}px;
|
|
|
|
padding: 0 ${resourcePaddingXS}px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
};
|
2023-07-20 19:27:33 +08:00
|
|
|
});
|
2022-11-09 12:28:04 +08:00
|
|
|
|
2023-02-03 13:39:46 +08:00
|
|
|
const ResourceLayout: React.FC<ResourceLayoutProps> = ({ children }) => {
|
2023-07-20 19:27:33 +08:00
|
|
|
const { styles } = useStyle();
|
2022-11-09 12:28:04 +08:00
|
|
|
const meta = useRouteMeta();
|
|
|
|
return (
|
2022-11-17 18:33:44 +08:00
|
|
|
<ConfigProvider theme={{ token: { colorBgLayout: '#fff' } }}>
|
|
|
|
<Layout>
|
|
|
|
<CommonHelmet />
|
2023-07-20 19:27:33 +08:00
|
|
|
<div id="resources-page" className={styles.resourcePage}>
|
2022-11-17 18:33:44 +08:00
|
|
|
<AffixTabs />
|
2023-07-20 19:27:33 +08:00
|
|
|
<div className={styles.banner}>
|
2022-11-17 18:33:44 +08:00
|
|
|
<Typography.Title style={{ fontSize: 30 }}>
|
2022-12-01 12:21:42 +08:00
|
|
|
{meta.frontmatter?.title}
|
2022-11-17 18:33:44 +08:00
|
|
|
<EditButton
|
|
|
|
title={<FormattedMessage id="app.content.edit-page" />}
|
|
|
|
filename={meta.frontmatter.filename}
|
|
|
|
/>
|
|
|
|
</Typography.Title>
|
|
|
|
<section>{meta.frontmatter.description}</section>
|
|
|
|
</div>
|
2023-07-20 19:27:33 +08:00
|
|
|
<div className={styles.resourceContent}>{children}</div>
|
2022-11-17 18:33:44 +08:00
|
|
|
<Footer />
|
2022-11-09 12:28:04 +08:00
|
|
|
</div>
|
2022-11-17 18:33:44 +08:00
|
|
|
</Layout>
|
|
|
|
</ConfigProvider>
|
2022-11-09 12:28:04 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ResourceLayout;
|