upcontent 0.1.4 → 0.1.5
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.
|
@@ -68,7 +68,7 @@ The optional fields below cover navigation, Starlight presentation, and content
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"navigation": {
|
|
71
|
-
"roots": ["
|
|
71
|
+
"roots": ["index.md", "guides"],
|
|
72
72
|
"labelOverrides": { "api": "API reference" },
|
|
73
73
|
"blocklist": {
|
|
74
74
|
"exact": ["notes.md"],
|
|
@@ -7,7 +7,7 @@ sidebar:
|
|
|
7
7
|
|
|
8
8
|
The sidebar is generated from the consumer file structure. Use configuration when the default filesystem order is not the right experience for readers.
|
|
9
9
|
|
|
10
|
-
If the repository has a root `index.md`, it becomes the website homepage and
|
|
10
|
+
If the repository has a root `index.md`, it becomes the website homepage and the root `README.md` remains GitHub-only. Repositories without `index.md` keep the backwards-compatible behavior where `README.md` is the homepage.
|
|
11
11
|
|
|
12
12
|
## Select top-level roots
|
|
13
13
|
|
package/package.json
CHANGED
package/src/content.config.ts
CHANGED
|
@@ -86,6 +86,7 @@ function portalDocsLoader(): Loader {
|
|
|
86
86
|
const homepage = hasRootIndex(docsBasePath) ? 'index' : 'readme'
|
|
87
87
|
const patterns = [
|
|
88
88
|
'**/[^_]*.{markdown,mdown,mkdn,mkd,mdwn,md,mdx}',
|
|
89
|
+
...(homepage === 'index' ? ['![rR][eE][aA][dD][mM][eE].{markdown,mdown,mkdn,mkd,mdwn,md,mdx}'] : []),
|
|
89
90
|
...getBlocklist().map(blocked => `!${toCaseInsensitiveGlob(blocked)}${blocked.endsWith('/') ? '**' : ''}`),
|
|
90
91
|
]
|
|
91
92
|
const wrappedContext: LoaderContext = {
|
package/src/lib/sidebar.test.ts
CHANGED
|
@@ -98,7 +98,7 @@ describe('buildSidebar', () => {
|
|
|
98
98
|
mountFs(ROOT, { 'index.md': null, guides: { 'guide.md': null } })
|
|
99
99
|
|
|
100
100
|
const sidebar = buildSidebar(ROOT)
|
|
101
|
-
expect(sidebar[0]).toEqual({ slug: 'index', label: '
|
|
101
|
+
expect(sidebar[0]).toEqual({ slug: 'index', label: 'Getting Started' })
|
|
102
102
|
})
|
|
103
103
|
|
|
104
104
|
it('ignora dotfiles e dot-directories', () => {
|
|
@@ -110,13 +110,13 @@ describe('buildSidebar', () => {
|
|
|
110
110
|
it('ignora arquivos bloqueados (floor hardcoded)', () => {
|
|
111
111
|
mountFs(ROOT, { 'CLAUDE.md': null, 'README.md': null })
|
|
112
112
|
const sidebar = buildSidebar(ROOT)
|
|
113
|
-
expect(sidebar).toEqual([{ slug: 'index', label: '
|
|
113
|
+
expect(sidebar).toEqual([{ slug: 'index', label: 'Getting Started' }])
|
|
114
114
|
})
|
|
115
115
|
|
|
116
|
-
it('fixa o README em primeiro, relabelado como
|
|
116
|
+
it('fixa o README em primeiro, relabelado como Getting Started, na frente de tudo', () => {
|
|
117
117
|
mountFs(ROOT, { 'README.md': null, domains: { historico: { 'a.md': null } } })
|
|
118
118
|
const sidebar = buildSidebar(ROOT) as { label: string }[]
|
|
119
|
-
expect(sidebar[0]).toEqual({ slug: 'index', label: '
|
|
119
|
+
expect(sidebar[0]).toEqual({ slug: 'index', label: 'Getting Started' })
|
|
120
120
|
expect(sidebar[1].label).toBe('Historico')
|
|
121
121
|
})
|
|
122
122
|
|
|
@@ -130,11 +130,11 @@ describe('buildSidebar', () => {
|
|
|
130
130
|
expect(sidebar[0]).toEqual({ slug: 'index', label: 'Docs' })
|
|
131
131
|
})
|
|
132
132
|
|
|
133
|
-
it('
|
|
133
|
+
it('não publica README quando index.md é a homepage', () => {
|
|
134
134
|
mountFs(ROOT, { 'README.md': null, 'index.markdown': null, domains: { historico: { 'a.md': null } } })
|
|
135
135
|
const sidebar = buildSidebar(ROOT) as { slug?: string; label?: string }[]
|
|
136
|
-
expect(sidebar[0]).toEqual({ slug: 'index', label: '
|
|
137
|
-
expect(sidebar).toContainEqual({ slug: 'readme', label: 'Readme' })
|
|
136
|
+
expect(sidebar[0]).toEqual({ slug: 'index', label: 'Getting Started' })
|
|
137
|
+
expect(sidebar).not.toContainEqual({ slug: 'readme', label: 'Readme' })
|
|
138
138
|
})
|
|
139
139
|
|
|
140
140
|
it('aplica labelOverrides do .upcontent/config.json em cima do Title Case', () => {
|
package/src/lib/sidebar.ts
CHANGED
|
@@ -98,8 +98,11 @@ export function buildSidebar(docsRoot: string): SidebarEntry[] {
|
|
|
98
98
|
const homepage = hasRootIndex(docsRoot) ? 'index' : 'readme'
|
|
99
99
|
const configuredRoots = getPortalConfig().navigation?.roots
|
|
100
100
|
const visibleTopLevel = configuredRoots
|
|
101
|
-
? topLevel.filter(({ name, isDir }) =>
|
|
102
|
-
|
|
101
|
+
? topLevel.filter(({ name, isDir }) =>
|
|
102
|
+
!(homepage === 'index' && !isDir && toSidebarSlug(name, homepage) === 'readme')
|
|
103
|
+
&& (configuredRoots.includes(name) || (!isDir && ['index', 'readme'].includes(toSidebarSlug(name, homepage))))
|
|
104
|
+
)
|
|
105
|
+
: topLevel.filter(({ name, isDir }) => !(homepage === 'index' && !isDir && toSidebarSlug(name, homepage) === 'readme'))
|
|
103
106
|
|
|
104
107
|
const entries: SidebarEntry[] = []
|
|
105
108
|
for (const { name, isDir } of visibleTopLevel) {
|
|
@@ -118,5 +121,5 @@ export function buildSidebar(docsRoot: string): SidebarEntry[] {
|
|
|
118
121
|
const homepageIndex = entries.findIndex(e => !isSidebarGroup(e) && e.slug === 'index')
|
|
119
122
|
const homepageEntry = homepageIndex >= 0 ? entries.splice(homepageIndex, 1)[0] : undefined
|
|
120
123
|
const sorted = sortEntries(entries)
|
|
121
|
-
return homepageEntry ? [{ slug: 'index', label: resolveLabel(homepage, '
|
|
124
|
+
return homepageEntry ? [{ slug: 'index', label: resolveLabel(homepage, 'Getting Started') }, ...sorted] : sorted
|
|
122
125
|
}
|