MCPcopy Create free account
hub / github.com/editablejs/editable / getSegments

Function getSegments

apps/docs/src/pages/[[...markdownPath]].js:218–229  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

216 // 'foo/bar/baz.md' -> ['foo', 'bar', 'baz']
217 // 'foo/bar/qux/index.md' -> ['foo', 'bar', 'qux']
218 function getSegments(file) {
219 const locale = context.locales.find(locale => file.endsWith(`.${locale}.md`))
220 let segments = file
221 .slice(0, (locale ? -locale.length - 1 : 0) - 3)
222 .replace(/\\/g, '/')
223 .split('/')
224
225 if (segments[segments.length - 1] === 'index') {
226 segments.pop()
227 }
228 return [segments, locale]
229 }
230
231 const files = await getFiles(rootDir)
232

Callers 1

getStaticPathsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…