Browse Source

docs: fix page h1

pull/40674/head
MadCcc 2 years ago
parent
commit
0e974511ad
  1. 2
      .dumi/theme/slots/Content/index.tsx
  2. 21
      scripts/check-site.js

2
.dumi/theme/slots/Content/index.tsx

@ -187,7 +187,7 @@ const Content: React.FC<{ children: ReactNode }> = ({ children }) => {
</section>
</Affix>
<article css={styles.articleWrapper} className={classNames({ rtl: isRTL })}>
{meta.frontmatter?.title && meta.frontmatter.subtitle ? (
{meta.frontmatter?.title ? (
<Typography.Title style={{ fontSize: 30 }}>
{meta.frontmatter?.title}
{meta.frontmatter.subtitle && (

21
scripts/check-site.js

@ -9,8 +9,7 @@ const { createServer } = require('http-server');
const components = uniq(
glob
.sync('components/*/*.md', {
ignore: '**/{__tests__,_util,version,index.tsx}',
.sync('components/!(overview)/*.md', {
cwd: join(process.cwd()),
dot: false,
})
@ -35,13 +34,13 @@ describe('site test', () => {
const handleComponentName = (name) => {
const componentName = name.split('/')[1];
return componentName.toLowerCase().replace('-', '');
return componentName.toLowerCase().replace('-cn', '').replace('-', '');
};
const expectComponent = async (component) => {
const { status, $ } = await render(`/${component}/`);
expect(status).toBe(200);
expect($('main h1').text().toLowerCase()).toMatch(handleComponentName(component));
expect($('h1').text().toLowerCase()).toMatch(handleComponentName(component));
};
beforeAll(() => {
@ -73,10 +72,22 @@ describe('site test', () => {
expect(status).toBe(200);
});
it('Overview en', async () => {
const { status, $ } = await render('/components/overview');
expect(status).toBe(200);
expect($('h1').text()).toMatch(`Overview`);
});
it('Overview zh', async () => {
const { status, $ } = await render('/components/overview-cn');
expect(status).toBe(200);
expect($('h1').text()).toMatch(`组件总览`);
});
for (const component of components) {
if (component.split('/').length < 3) {
it(`Component ${component} zh Page`, async () => {
await expectComponent(component);
await expectComponent(`${component}-cn`);
});
it(`Component ${component} en Page`, async () => {

Loading…
Cancel
Save