File size: 522 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { FlattenedNavigation } from './navigation'

const BASE_URL =
  'https://github.com/pmndrs/react-spring/tree/main/docs/app/routes'

export const getDocFilePathToGithub = (item?: FlattenedNavigation): string => {
  if (!item) {
    return BASE_URL
  }

  let filePath = item.href.split('/docs/')[1]

  if (!filePath) {
    filePath = '_index'
  } else {
    filePath = filePath.replace(/\//g, '.')
  }

  if (item.hasChildren) {
    filePath = `${filePath}._index`
  }

  return `${BASE_URL}/docs.${filePath}.mdx`
}