mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-11-04 18:07:26 +03:00 
			
		
		
		
	Redirect index.mdx to parent directory
				
					
				
			This commit is contained in:
		
							parent
							
								
									dcf8455f77
								
							
						
					
					
						commit
						978045b36b
					
				| 
						 | 
					@ -39,7 +39,10 @@ export const getStaticPaths: GetStaticPaths<ParsedUrlQuery> = async () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return {
 | 
					                return {
 | 
				
			||||||
                    params: {
 | 
					                    params: {
 | 
				
			||||||
                        listPathPage: [...pathBase, dirent.name.replace('.mdx', '')],
 | 
					                        listPathPage:
 | 
				
			||||||
 | 
					                            dirent.name === 'index.mdx'
 | 
				
			||||||
 | 
					                                ? pathBase
 | 
				
			||||||
 | 
					                                : [...pathBase, dirent.name.replace('.mdx', '')],
 | 
				
			||||||
                    },
 | 
					                    },
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
| 
						 | 
					@ -50,20 +53,25 @@ export const getStaticPaths: GetStaticPaths<ParsedUrlQuery> = async () => {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const getPathFileWithExtension = (listPathFile: ReadonlyArray<string>) =>
 | 
				
			||||||
 | 
					    `${path.join(...listPathFile)}.mdx`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getStaticProps: GetStaticProps<PropsPage, ParsedUrlQuery> = async (args) => {
 | 
					export const getStaticProps: GetStaticProps<PropsPage, ParsedUrlQuery> = async (args) => {
 | 
				
			||||||
    if (!args.params) {
 | 
					    if (!args.params) {
 | 
				
			||||||
        return { notFound: true }
 | 
					        return { notFound: true }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const mdx = await serialize(
 | 
					    const listPathFile = ['docs', ...args.params.listPathPage]
 | 
				
			||||||
        fs.readFileSync(`${path.join('docs', ...args.params.listPathPage)}.mdx`, 'utf-8'),
 | 
					    const isIndex = fs.existsSync(getPathFileWithExtension(listPathFile)) !== true
 | 
				
			||||||
        {
 | 
					    const listPathFileWithIndex = isIndex ? [...listPathFile, 'index'] : listPathFile
 | 
				
			||||||
 | 
					    const listPathFileWithIndexAndExtension = getPathFileWithExtension(listPathFileWithIndex)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const mdx = await serialize(fs.readFileSync(listPathFileWithIndexAndExtension, 'utf-8'), {
 | 
				
			||||||
        parseFrontmatter: true,
 | 
					        parseFrontmatter: true,
 | 
				
			||||||
        mdxOptions: {
 | 
					        mdxOptions: {
 | 
				
			||||||
            remarkPlugins,
 | 
					            remarkPlugins,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        }
 | 
					    })
 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        props: {
 | 
					        props: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user