1- import { useState , useEffect , useRef } from 'react'
1+ import * as React from 'react'
22import cx from 'classnames'
33import { MDXProvider } from '@mdx-js/react'
44import { Helmet } from 'react-helmet'
@@ -7,15 +7,16 @@ import Link from './Link'
77import Loading from '../component/Loading'
88import styles from './style/index.less'
99
10+ const { useState, useEffect, useRef } = React
11+
1012const components = {
1113 code : CodeBlock ,
1214 link : Link ,
1315}
1416
1517function 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