@docubook/flame 1.4.0 → 1.4.2

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.
@@ -37,6 +37,12 @@ export default function Menu({ onNavigate, className = "", pathname, routes = []
37
37
 
38
38
  const mode = docuConfig.sidebar?.context || "dropdown";
39
39
 
40
+ // Helper: check if a sublink under a given route matches the current path
41
+ const isItemActive = (itemHref: string, parentRouteHref: string) => {
42
+ const fullHref = `/docs${parentRouteHref}${itemHref}`;
43
+ return currentPath === fullHref || currentPath === `${fullHref}.html`;
44
+ };
45
+
40
46
  // Separator mode: render all context sections as group headers + nav items
41
47
  if (mode === "separator") {
42
48
  const contextRoutes = menuRoutes.filter((r) => r.context);
@@ -48,7 +54,7 @@ export default function Menu({ onNavigate, className = "", pathname, routes = []
48
54
  aria-label="Documentation navigation"
49
55
  className={cn("transition-all duration-200", className)}
50
56
  >
51
- <ul className="flex flex-col gap-1.5 py-4">
57
+ <ul className="flex flex-col gap-0.5 py-4">
52
58
  {menuRoutes.map((route) => (
53
59
  <li key={route.href}>
54
60
  <Sublink
@@ -76,18 +82,30 @@ export default function Menu({ onNavigate, className = "", pathname, routes = []
76
82
  icon={route.context?.icon}
77
83
  title={route.context?.title || route.title}
78
84
  />
79
- <ul className="border-base-300 flex flex-col gap-1.5 border-l-2 pb-0.5 pl-3 pt-0.5">
80
- {route.items?.map((item) => (
81
- <li key={item.href}>
82
- <Sublink
83
- {...item}
84
- href={item.href}
85
- level={0}
86
- onNavigate={onNavigate}
87
- parentHref={`/docs${route.href}`}
88
- />
89
- </li>
90
- ))}
85
+ <ul className="border-base-300 flex flex-col gap-0.5 border-l-2 pb-0.5 pl-3 pt-0.5">
86
+ {route.items?.map((item) => {
87
+ const isActive = isItemActive(item.href, route.href);
88
+ return (
89
+ <li key={item.href}>
90
+ <div
91
+ className={cn(
92
+ "-ml-[14px] border-l-2",
93
+ isActive ? "border-primary" : "border-transparent"
94
+ )}
95
+ >
96
+ <div className="pl-3">
97
+ <Sublink
98
+ {...item}
99
+ href={item.href}
100
+ level={0}
101
+ onNavigate={onNavigate}
102
+ parentHref={`/docs${route.href}`}
103
+ />
104
+ </div>
105
+ </div>
106
+ </li>
107
+ );
108
+ })}
91
109
  </ul>
92
110
  </div>
93
111
  ))}
@@ -117,7 +135,7 @@ export default function Menu({ onNavigate, className = "", pathname, routes = []
117
135
  aria-label="Documentation navigation"
118
136
  className={cn("transition-all duration-200", className)}
119
137
  >
120
- <ul className="flex flex-col gap-1.5 py-4">
138
+ <ul className="flex flex-col gap-0.5 py-4">
121
139
  <li key={contextRoute.title}>
122
140
  <Sublink
123
141
  {...contextRoute}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { useState } from "react";
3
+ import { useState, useRef, useEffect } from "react";
4
4
  import { ChevronDown } from "lucide-react";
5
5
  import Anchor from "./Anchor";
6
6
  import type { DocuRoute } from "../node/types";
@@ -35,11 +35,17 @@ export default function Sublink({
35
35
 
36
36
  // Shared padding based on nesting level
37
37
  const levelPadding = cn(level === 1 && "pl-2", level === 2 && "pl-4", level >= 3 && "pl-6");
38
+ const isActive = currentPathname === fullHref || currentPathname === `${fullHref}.html`;
39
+ const activeRef = useRef<HTMLDivElement>(null);
40
+
41
+ useEffect(() => {
42
+ if (isActive && activeRef.current) {
43
+ activeRef.current.scrollIntoView({ block: "nearest" });
44
+ }
45
+ }, [isActive]);
38
46
 
39
47
  // Leaf node (no children)
40
48
  if (!items) {
41
- const isActive = currentPathname === fullHref || currentPathname === `${fullHref}.html`;
42
-
43
49
  const link = (
44
50
  <Anchor
45
51
  href={fullHref}
@@ -51,10 +57,12 @@ export default function Sublink({
51
57
  {title}
52
58
  </Anchor>
53
59
  );
60
+
54
61
  return (
55
62
  <div
63
+ ref={activeRef}
56
64
  className={cn(
57
- "py-1.5",
65
+ "py-1",
58
66
  levelPadding,
59
67
  level >= 2 && "border-l-2",
60
68
  level >= 2 && (isActive ? "border-primary" : "border-base-300")
@@ -67,7 +75,7 @@ export default function Sublink({
67
75
 
68
76
  // Section with children
69
77
  return (
70
- <div className={cn("flex flex-col", levelPadding)}>
78
+ <div ref={isActive ? activeRef : undefined} className={cn("flex flex-col", levelPadding)}>
71
79
  {/* Section header */}
72
80
  <button
73
81
  type="button"
@@ -102,7 +110,7 @@ export default function Sublink({
102
110
 
103
111
  {/* Children */}
104
112
  {isOpen && (
105
- <div className="flex flex-col py-1.5">
113
+ <div className="flex flex-col py-1">
106
114
  {items.map((item) => (
107
115
  <Sublink
108
116
  key={`${fullHref}${item.href}`}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docubook/flame",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "A blazing-fast React + MDX framework powered by Bun, built for modern documentation experiences.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,10 +52,10 @@
52
52
  "react": "^19.2.7",
53
53
  "react-dom": "^19.2.7",
54
54
  "unified": "^11.0.0",
55
- "@docubook/mdx-content": "^3.2.2",
56
- "@docubook/themes-colors": "^0.10.2",
57
- "@docubook/core": "^1.7.2",
58
- "@docubook/ui-react": "^0.1.4"
55
+ "@docubook/core": "^1.8.0",
56
+ "@docubook/mdx-content": "^3.4.0",
57
+ "@docubook/ui-react": "^0.1.4",
58
+ "@docubook/themes-colors": "^0.10.2"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@sentry/bun": "^10.0.0"