Skip to content

Commit c8f0792

Browse files
committed
feat: optimize seo title
1 parent 6490e36 commit c8f0792

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

packages/crd-scripts/src/web/Router.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@ function menuSourceFormat(data, routePath, article) {
2929
const routePropsCurrent = `${routePath || ''}/${item.name}`.replace(/.md$/, '')
3030
if (item.type === 'directory') {
3131
if (item.children && item.children.length > 0) {
32-
item.title = 'test aaa'
33-
// item.title = item.name.replace(item.extension, '')
32+
item.title = item.name.replace(item.extension, '')
3433
item.mdconf = {}
3534
item.props = { isEmpty: true }
3635
item.children = menuSourceFormat(item.children, routePropsCurrent, article || item.name)
3736
} else {
38-
item.title = 'test bbb'
39-
// item.title = item.name.replace(item.extension, '')
37+
item.title = item.name.replace(item.extension, '')
4038
item.mdconf = { title: item.name }
4139
item.props = { isEmpty: true }
4240
item.children = []
4341
}
4442
} else {
45-
item.title = 'test ccc'
46-
// item.title = item.mdconf && item.mdconf.title ? item.mdconf.title : item.name.replace(item.extension, '')
43+
item.title = item.mdconf && item.mdconf.title ? item.mdconf.title : item.name.replace(item.extension, '')
4744
if (!item.mdconf) {
4845
item.props = { isEmpty: true }
4946
}

packages/crd-seed/component/Header/index.js

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/crd-seed/layout/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ function BasicLayout({
230230
{/* see https://reacttraining.com/react-router/web/api/Redirect/exact-bool */}
231231
<Redirect exact from={ifAddPrefix ? `/${repo}` : `/`} to={ifAddPrefix ? `/${repo}/${defaultPath}` : `/${defaultPath}`} />
232232
{routeData.map((item) => {
233-
console.log('item', item)
234233
const { path, mdconf, component } = item
235234
const { abbrlink } = mdconf
236235
const enhancePath = abbrlink ? `/${abbrlink}` : path

packages/crd-theme/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable global-require */
21
// import Loading from './component/Loading'
32
import Markdown from './routes/Pages'
43
// import { ifProd, ifPrerender } from './utils'
@@ -23,6 +22,7 @@ export default function (Lazyload, props) {
2322

2423
// support for custom theme.
2524
const CustomTheme = require('__project_theme__').default
25+
2626
return (
2727
// use custom theme here.
2828
<CustomTheme {...props} />

packages/crd-theme/markdown/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect, useRef } from 'react'
1+
import * as React from 'react'
22
import cx from 'classnames'
33
import { MDXProvider } from '@mdx-js/react'
44
import { Helmet } from 'react-helmet'
@@ -7,15 +7,16 @@ import Link from './Link'
77
import Loading from '../component/Loading'
88
import styles from './style/index.less'
99

10+
const { useState, useEffect, useRef } = React
11+
1012
const components = {
1113
code: CodeBlock,
1214
link: Link,
1315
}
1416

1517
function Markdown(markdownProps) {
1618
const { props } = markdownProps
17-
const { relative } = props
18-
console.log('props', props)
19+
const { relative, name } = props
1920
const [MarkdownCP, setMarkdownCP] = useState(null)
2021
const markdownWrapperRef = useRef(null)
2122

@@ -35,15 +36,15 @@ function Markdown(markdownProps) {
3536
renderMarkdown()
3637
}, [])
3738

38-
useEffect(() => {
39-
// to test
40-
}, [props.title])
39+
const getName = () => {
40+
return name ? name.replace('.md', '') : ''
41+
}
4142

4243
return (
4344
<>
4445
<Helmet>
45-
<title>{props.title}</title>
46-
<meta name={props.title} content={props.title} />
46+
<title>{getName()}</title>
47+
<meta name={getName()} content={getName()} />
4748
</Helmet>
4849
<div className={cx('markdown', styles.markdown, styles.markdownwrapper)} ref={markdownWrapperRef}>
4950
{

0 commit comments

Comments
 (0)