• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vuepress / vuepress-next / 7353675564

29 Dec 2023 04:14AM UTC coverage: 69.529%. Remained the same
7353675564

push

github

meteorlxy
feat: bump to vue 3.4

338 of 471 branches covered (0.0%)

Branch coverage included in aggregate %.

650 of 950 relevant lines covered (68.42%)

52.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.33
/packages/core/src/app/prepare/preparePagesRoutes.ts
1
import type { PageRouteItem } from '@vuepress/client'
2
import { ensureLeadingSlash } from '@vuepress/shared'
3
import type { App, Page } from '../../types/index.js'
4

5
/**
6
 * Resolve page route item
7
 */
8
const resolvePageRouteItem = ({
27✔
9
  key,
10
  path,
11
  pathInferred,
12
  filePathRelative,
13
  routeMeta,
14
}: Page): PageRouteItem => {
15
  // paths that should redirect to this page, use set to dedupe
16
  const redirectsSet = new Set<string>()
×
17

18
  // redirect from decoded path
19
  redirectsSet.add(decodeURI(path))
×
20

21
  // redirect from inferred path
22
  if (pathInferred !== null) {
×
23
    redirectsSet.add(pathInferred)
×
24
    redirectsSet.add(encodeURI(pathInferred))
×
25
  }
26

27
  // redirect from filename path
28
  if (filePathRelative !== null) {
×
29
    const filenamePath = ensureLeadingSlash(filePathRelative)
×
30
    redirectsSet.add(filenamePath)
×
31
    redirectsSet.add(encodeURI(filenamePath))
×
32
  }
33

34
  // avoid redirect from the page path itself
35
  redirectsSet.delete(path)
×
36

37
  return [
×
38
    key,
39
    path,
40
    routeMeta,
41
    [...redirectsSet].map((item) =>
42
      item.replace(/\.md$/, '.html') === path ? ':md' : item,
×
43
    ),
44
  ]
45
}
46

47
/**
48
 * Generate routes temp file
49
 */
50
export const preparePagesRoutes = async (app: App): Promise<void> => {
27✔
51
  const routeItems = app.pages.map(resolvePageRouteItem)
×
52
  const content = `\
×
53
export const pagesRoutes = [\
54
${routeItems.map((routeItem) => `\n  ${JSON.stringify(routeItem)},`).join('')}
×
55
]
56
`
57

58
  await app.writeTemp('internal/pagesRoutes.js', content)
×
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc