Skip to content

Commit

Permalink
feat(api): add route that allows scrape specific docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobsonOlv committed Mar 22, 2024
1 parent f2a9965 commit b4051ac
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/pages/api/docs/[slug].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// import { getAllDocsPaths } from 'utils/getDocsPaths'

// const allPaths = await getAllDocsPaths()
//eslint-disable-next-line @typescript-eslint/no-explicit-any
export default async function handler(req: any, res: any) {
const { slug, language, path }: { [key: string]: string } = req.query
const docCategory = path.split('/')[1]
let doc = ''

if (docCategory === 'tutorials') {
doc = 'docs/tutorial'
} else if (docCategory === 'tracks') {
doc = 'docs/tracks'
} else {
doc = docCategory
}

const url = `/${language ? `${language}/` : ''}${doc}/${slug}`
res.redirect(307, url)
}

0 comments on commit b4051ac

Please sign in to comment.