@docsector/docsector-reader 1.7.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +2 -0
- package/README.md +91 -9
- package/bin/docsector.js +27 -13
- package/package.json +1 -1
- package/src/components/DH1.vue +2 -1
- package/src/components/DMenu.vue +70 -30
- package/src/components/DMenuItem.vue +12 -6
- package/src/components/DPage.vue +124 -31
- package/src/components/DPageAnchor.vue +13 -1
- package/src/components/DPageBar.vue +2 -1
- package/src/components/DPageMeta.vue +9 -4
- package/src/components/DPageSection.vue +2 -1
- package/src/composables/useWebMcp.js +2 -1
- package/src/i18n/helpers.js +36 -9
- package/src/i18n/index.js +2 -2
- package/src/i18n/path.js +101 -0
- package/src/index.js +25 -2
- package/src/layouts/DefaultLayout.vue +181 -2
- package/src/pages/guide/getting-started.overview.en-US.md +3 -2
- package/src/pages/guide/getting-started.overview.pt-BR.md +3 -2
- package/src/pages/guide/pages-and-routing.overview.en-US.md +6 -6
- package/src/pages/guide/pages-and-routing.overview.pt-BR.md +6 -6
- package/src/pages/guide.book.js +12 -0
- package/src/pages/guide.index.js +184 -0
- package/src/pages/manual.book.js +12 -0
- package/src/pages/{index.js → manual.index.js} +13 -216
- package/src/quasar.factory.js +370 -49
- package/src/router/routes.js +132 -46
package/src/router/routes.js
CHANGED
|
@@ -1,59 +1,144 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { books } from 'virtual:docsector-books'
|
|
2
2
|
import boot from 'pages/boot'
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
continue
|
|
4
|
+
const normalizeInternalLink = (linkTo) => {
|
|
5
|
+
const normalized = String(linkTo || '').trim()
|
|
6
|
+
if (normalized.length === 0) {
|
|
7
|
+
return '/'
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
return normalized.startsWith('/') ? normalized : `/${normalized}`
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
const normalizeRoutePath = (path) => {
|
|
14
|
+
const normalized = String(path || '')
|
|
15
|
+
.trim()
|
|
16
|
+
.replace(/^\/+/, '/')
|
|
17
|
+
.replace(/\/+$/, '')
|
|
18
|
+
|
|
19
|
+
if (normalized === '') {
|
|
20
|
+
return '/'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return normalized.startsWith('/') ? normalized : `/${normalized}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const resolveInternalLinkBasePath = (linkTo) => {
|
|
27
|
+
const normalized = normalizeInternalLink(linkTo)
|
|
28
|
+
const withoutTrailingSlash = normalized.replace(/\/+$/, '')
|
|
29
|
+
const withoutSubpage = withoutTrailingSlash.replace(/\/(overview|showcase|vs)$/i, '')
|
|
30
|
+
|
|
31
|
+
return normalizeRoutePath(withoutSubpage || '/')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const routeConfigByPath = new Map()
|
|
35
|
+
for (const [bookId, book] of Object.entries(books || {})) {
|
|
36
|
+
const bookRoutes = book?.routes || {}
|
|
37
|
+
|
|
38
|
+
for (const [path, page] of Object.entries(bookRoutes)) {
|
|
39
|
+
const config = page?.config
|
|
40
|
+
if (config === null) {
|
|
41
|
+
continue
|
|
25
42
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
meta: {
|
|
32
|
-
status: config.status
|
|
33
|
-
}
|
|
34
|
-
})
|
|
43
|
+
|
|
44
|
+
const topPage = config?.book ?? config?.type ?? bookId ?? 'manual'
|
|
45
|
+
const routePath = normalizeRoutePath('/' + topPage + path)
|
|
46
|
+
|
|
47
|
+
routeConfigByPath.set(routePath, config || {})
|
|
35
48
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const pagesRoutes = []
|
|
52
|
+
for (const [bookId, book] of Object.entries(books || {})) {
|
|
53
|
+
const bookRoutes = book?.routes || {}
|
|
54
|
+
|
|
55
|
+
for (const [path, page] of Object.entries(bookRoutes)) {
|
|
56
|
+
const rawConfig = page.config
|
|
57
|
+
if (rawConfig === null) {
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const config = rawConfig || {}
|
|
62
|
+
const menu = (typeof config.menu === 'object' && config.menu !== null) ? config.menu : {}
|
|
63
|
+
const subpages = {
|
|
64
|
+
showcase: config?.subpages?.showcase === true,
|
|
65
|
+
vs: config?.subpages?.vs === true
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const topPage = config.book ?? config.type ?? bookId ?? 'manual'
|
|
69
|
+
const hasInternalLink = typeof config?.link?.to === 'string' && config.link.to.trim().length > 0
|
|
70
|
+
const internalLinkTo = hasInternalLink ? normalizeInternalLink(config.link.to) : null
|
|
71
|
+
const linkedConfig = hasInternalLink
|
|
72
|
+
? routeConfigByPath.get(resolveInternalLinkBasePath(config.link.to))
|
|
73
|
+
: null
|
|
74
|
+
const icon = config.icon ?? linkedConfig?.icon
|
|
75
|
+
const status = typeof config.status === 'string'
|
|
76
|
+
? config.status
|
|
77
|
+
: (typeof linkedConfig?.status === 'string' ? linkedConfig.status : 'done')
|
|
78
|
+
|
|
79
|
+
// @ Construct children
|
|
80
|
+
const children = hasInternalLink
|
|
81
|
+
? [
|
|
82
|
+
{
|
|
83
|
+
path: '',
|
|
84
|
+
redirect: () => internalLinkTo
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
path: 'overview',
|
|
88
|
+
redirect: () => internalLinkTo
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
: [
|
|
92
|
+
{
|
|
93
|
+
path: '',
|
|
94
|
+
redirect: (to) => `${to.path.replace(/\/$/, '')}/overview/`
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
path: 'overview',
|
|
98
|
+
component: () => import('components/DSubpage.vue'),
|
|
99
|
+
meta: {
|
|
100
|
+
status
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
if (!hasInternalLink && subpages.showcase === true) {
|
|
106
|
+
children.push({
|
|
107
|
+
path: 'showcase',
|
|
108
|
+
component: () => import('components/DSubpage.vue'),
|
|
109
|
+
meta: {
|
|
110
|
+
status
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
if (!hasInternalLink && subpages.vs === true) {
|
|
115
|
+
children.push({
|
|
116
|
+
path: 'vs',
|
|
117
|
+
component: () => import('components/DSubpage.vue'),
|
|
118
|
+
meta: {
|
|
119
|
+
status
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// @ Push route to pageRoutes
|
|
125
|
+
pagesRoutes.push({
|
|
126
|
+
path: '/' + topPage + path,
|
|
127
|
+
component: () => import('layouts/DefaultLayout.vue'),
|
|
40
128
|
meta: {
|
|
41
|
-
|
|
42
|
-
|
|
129
|
+
...config,
|
|
130
|
+
icon,
|
|
131
|
+
status,
|
|
132
|
+
menu,
|
|
133
|
+
subpages,
|
|
134
|
+
data: page.data,
|
|
135
|
+
book: topPage,
|
|
136
|
+
// legacy compatibility
|
|
137
|
+
type: topPage
|
|
138
|
+
},
|
|
139
|
+
children
|
|
43
140
|
})
|
|
44
141
|
}
|
|
45
|
-
|
|
46
|
-
// @ Push route to pageRoutes
|
|
47
|
-
pagesRoutes.push({
|
|
48
|
-
path: '/' + topPage + path,
|
|
49
|
-
component: () => import('layouts/DefaultLayout.vue'),
|
|
50
|
-
meta: {
|
|
51
|
-
...config,
|
|
52
|
-
data: page.data,
|
|
53
|
-
type: topPage
|
|
54
|
-
},
|
|
55
|
-
children
|
|
56
|
-
})
|
|
57
142
|
}
|
|
58
143
|
|
|
59
144
|
const routes = [
|
|
@@ -67,6 +152,7 @@ const routes = [
|
|
|
67
152
|
icon: 'home',
|
|
68
153
|
menu: {},
|
|
69
154
|
status: 'done',
|
|
155
|
+
book: 'home',
|
|
70
156
|
type: 'home',
|
|
71
157
|
subpages: {
|
|
72
158
|
showcase: false,
|