@aravindc26/velu 0.11.3 → 0.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -61,6 +61,11 @@ function init(targetDir: string) {
61
61
  const config = {
62
62
  $schema: "https://raw.githubusercontent.com/aravindc26/velu/main/schema/velu.schema.json",
63
63
  theme: "neutral" as const,
64
+ colors: {
65
+ primary: "#DC143C",
66
+ light: "#DC143C",
67
+ dark: "#DC143C",
68
+ },
64
69
  navigation: {
65
70
  tabs: [
66
71
  {
@@ -151,14 +151,19 @@ function buildNavbarTabs(tree: unknown): Array<{
151
151
  ? (tree as { children: unknown[] }).children
152
152
  : [];
153
153
 
154
- const rootFolder = rootChildren.find((child) => {
154
+ const rootFolders = rootChildren.filter((child) => {
155
155
  const node = child as PageTreeFolderNode;
156
156
  return node?.type === 'folder' && node.root === true;
157
- }) as PageTreeFolderNode | undefined;
157
+ }) as PageTreeFolderNode[];
158
158
 
159
- const tabFolders = Array.isArray(rootFolder?.children)
160
- ? rootFolder!.children.filter((child) => (child as PageTreeFolderNode)?.type === 'folder') as PageTreeFolderNode[]
161
- : rootChildren.filter((child) => (child as PageTreeFolderNode)?.type === 'folder') as PageTreeFolderNode[];
159
+ // Two shapes are supported:
160
+ // 1) Multiple root folders => each root folder is a top-level tab.
161
+ // 2) Single root folder containing tab folders as children.
162
+ const tabFolders: PageTreeFolderNode[] = rootFolders.length > 1
163
+ ? rootFolders
164
+ : (rootFolders.length === 1 && Array.isArray(rootFolders[0]?.children)
165
+ ? rootFolders[0].children.filter((child) => (child as PageTreeFolderNode)?.type === 'folder') as PageTreeFolderNode[]
166
+ : rootChildren.filter((child) => (child as PageTreeFolderNode)?.type === 'folder') as PageTreeFolderNode[]);
162
167
 
163
168
  const tabs = tabFolders
164
169
  .map((folder) => {
@@ -251,6 +256,30 @@ function scopeTreeToTab<T extends { children?: unknown[] }>(
251
256
  if (!normalizedTab) return tree;
252
257
 
253
258
  const topChildren = Array.isArray(tree.children) ? tree.children : [];
259
+ const rootFolders = topChildren.filter((child) => {
260
+ const node = child as PageTreeFolderNode;
261
+ return node?.type === 'folder' && node.root === true;
262
+ }) as PageTreeFolderNode[];
263
+
264
+ // When docs have multiple top-level root folders (tabs), avoid rendering
265
+ // the sidebar root switcher. Show only the active tab's children.
266
+ if (rootFolders.length > 1) {
267
+ const activeTopTab = (containerSlug ?? tabSlug ?? '').trim().toLowerCase();
268
+ if (!activeTopTab) return tree;
269
+
270
+ const matchedRoot = rootFolders.find((folder) => {
271
+ const urls = collectFolderUrls(folder);
272
+ for (const url of urls) {
273
+ const segments = url.split('/').filter(Boolean).map((segment) => segment.toLowerCase());
274
+ if ((segments[0] ?? '') === activeTopTab) return true;
275
+ }
276
+ return false;
277
+ });
278
+
279
+ if (!matchedRoot || !Array.isArray(matchedRoot.children)) return tree;
280
+ return { ...tree, children: matchedRoot.children } as T;
281
+ }
282
+
254
283
  const rootFolder = topChildren.find((child) => {
255
284
  const node = child as PageTreeFolderNode;
256
285
  return node?.type === 'folder' && node.root === true;
@@ -297,7 +326,6 @@ export default async function SlugLayout({ children, params }: SlugLayoutProps)
297
326
  const currentVersion = resolveCurrentVersion(resolvedParams.slug, versions);
298
327
  const currentProduct = resolveCurrentProduct(resolvedParams.slug, products);
299
328
  const { containerSlug, tabSlug: currentTabSlug } = resolveTabContext(resolvedParams.slug);
300
-
301
329
  const activePrefix = currentVersion?.slug ?? currentProduct?.slug;
302
330
  const containerScopedTree = filterTreeBySlugPrefix(source.getPageTree(locale), activePrefix);
303
331
  const rawTree = scopeTreeToTab(containerScopedTree, currentTabSlug, containerSlug);
@@ -602,8 +602,8 @@ nextjs-portal {
602
602
  .velu-page-feedback-row {
603
603
  display: flex;
604
604
  align-items: center;
605
- justify-content: space-between;
606
- gap: 0.75rem;
605
+ justify-content: flex-start;
606
+ gap: 0.55rem;
607
607
  flex-wrap: wrap;
608
608
  }
609
609
 
@@ -619,6 +619,7 @@ nextjs-portal {
619
619
  display: inline-flex;
620
620
  align-items: center;
621
621
  gap: 0.5rem;
622
+ margin-left: 0.1rem;
622
623
  }
623
624
 
624
625
  .velu-page-feedback-btn {