@docubook/flame 1.4.0 → 1.4.1

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);
@@ -77,17 +83,29 @@ export default function Menu({ onNavigate, className = "", pathname, routes = []
77
83
  title={route.context?.title || route.title}
78
84
  />
79
85
  <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
- ))}
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
  ))}
@@ -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,8 +57,10 @@ 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
65
  "py-1.5",
58
66
  levelPadding,
@@ -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"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docubook/flame",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
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,9 +52,9 @@
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",
55
+ "@docubook/core": "^1.8.0",
56
+ "@docubook/mdx-content": "^3.3.0",
56
57
  "@docubook/themes-colors": "^0.10.2",
57
- "@docubook/core": "^1.7.2",
58
58
  "@docubook/ui-react": "^0.1.4"
59
59
  },
60
60
  "peerDependencies": {