@docmd/ui 0.6.1 → 0.6.3

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.
@@ -557,6 +557,68 @@ body.sidebar-collapsed .main-content-wrapper {
557
557
  -webkit-backdrop-filter: blur(8px);
558
558
  }
559
559
 
560
+ .header-titles-wrapper {
561
+ display: flex;
562
+ flex-direction: column;
563
+ justify-content: center;
564
+ }
565
+
566
+ .docmd-breadcrumbs {
567
+ font-size: 0.8125rem;
568
+ color: var(--text-muted);
569
+ margin-bottom: var(--space-4);
570
+ display: block;
571
+ }
572
+
573
+ .docmd-breadcrumbs ol {
574
+ list-style: none;
575
+ padding: 0;
576
+ margin: 0;
577
+ display: flex;
578
+ align-items: center;
579
+ flex-wrap: wrap;
580
+ gap: 0.25rem;
581
+ }
582
+
583
+ .docmd-breadcrumbs li {
584
+ display: inline-flex;
585
+ align-items: center;
586
+ white-space: nowrap;
587
+ }
588
+
589
+ .docmd-breadcrumbs a {
590
+ color: var(--text-muted);
591
+ text-decoration: none;
592
+ transition: color 0.15s ease;
593
+ }
594
+
595
+ .docmd-breadcrumbs a:hover {
596
+ color: var(--link-color);
597
+ }
598
+
599
+ .docmd-breadcrumbs .breadcrumb-separator {
600
+ margin-left: 0.25rem;
601
+ opacity: 0.5;
602
+ display: inline-flex;
603
+ align-items: center;
604
+ }
605
+
606
+ .docmd-breadcrumbs .breadcrumb-separator .lucide-icon {
607
+ width: 0.8em;
608
+ height: 0.8em;
609
+ }
610
+
611
+ .docmd-breadcrumbs .active {
612
+ color: var(--text-color);
613
+ font-weight: 500;
614
+ }
615
+
616
+ @media (max-width: 768px) {
617
+ .docmd-breadcrumbs {
618
+ display: none;
619
+ }
620
+ }
621
+
560
622
  .page-header .header-title {
561
623
  font-size: 1.25rem;
562
624
  font-weight: 600;
@@ -75,28 +75,38 @@
75
75
  // Sticky Version Switching (Path Preservation)
76
76
  const versionLink = e.target.closest('.version-dropdown-item');
77
77
  if (versionLink) {
78
+ e.preventDefault(); // Prevent default link behavior immediately
78
79
  const targetRoot = versionLink.dataset.versionRoot;
79
80
  // Use global fallback if undefined (e.g. on 404 pages)
80
81
  const currentRoot = window.DOCMD_VERSION_ROOT || '/';
81
82
 
82
83
  if (targetRoot && window.location.pathname) {
83
- try {
84
- let currentPath = window.location.pathname;
85
- const normCurrentRoot = currentRoot.endsWith('/') ? currentRoot : currentRoot + '/';
86
-
87
- // Only try sticky if we are actually INSIDE the known version path
88
- if (currentPath.startsWith(normCurrentRoot)) {
89
- e.preventDefault();
90
- const suffix = currentPath.substring(normCurrentRoot.length);
91
- const normTargetRoot = targetRoot.endsWith('/') ? targetRoot : targetRoot + '/';
92
- window.location.href = normTargetRoot + suffix + window.location.hash;
93
- return;
94
- }
95
- } catch (e) {
96
- // Ignore errors, let default click happen
84
+ let currentPath = window.location.pathname;
85
+ const normCurrentRoot = currentRoot.endsWith('/') ? currentRoot : currentRoot + '/';
86
+
87
+ // Only try sticky if we are actually INSIDE the known version path
88
+ if (currentPath.startsWith(normCurrentRoot)) {
89
+ const suffix = currentPath.substring(normCurrentRoot.length);
90
+ const normTargetRoot = targetRoot.endsWith('/') ? targetRoot : targetRoot + '/';
91
+ const targetHref = normTargetRoot + suffix + window.location.hash;
92
+
93
+ // Smart Switcher: Check if the exact page exists in the target version
94
+ fetch(targetHref, { method: 'HEAD' })
95
+ .then(response => {
96
+ if (response.ok) {
97
+ window.location.href = targetHref; // Exact match found
98
+ } else {
99
+ window.location.href = normTargetRoot; // Fallback to version root
100
+ }
101
+ })
102
+ .catch(() => {
103
+ window.location.href = normTargetRoot; // Network error fallback
104
+ });
105
+ return;
97
106
  }
98
107
  }
99
- // If sticky logic skipped (e.g. on 404 page or outside root), default <a> click handles it
108
+ // If we are outside the root (or targetRoot is missing), just use the href defined in the link
109
+ window.location.href = versionLink.href;
100
110
  }
101
111
 
102
112
  // Close Dropdown if clicked outside
@@ -306,6 +316,7 @@
306
316
 
307
317
  const selectorsToSwap = [
308
318
  '.content-layout',
319
+ '.docmd-breadcrumbs',
309
320
  '.page-header .header-title',
310
321
  '.page-footer',
311
322
  '.footer-complete',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docmd/ui",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Base UI templates and assets for docmd.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -138,9 +138,11 @@
138
138
  <%- renderIcon('panel-left-close') %>
139
139
  </button>
140
140
  <% } %>
141
- <span class="header-title">
142
- <%= pageTitle %>
143
- </span>
141
+ <div class="header-titles-wrapper">
142
+ <span class="header-title">
143
+ <%= pageTitle %>
144
+ </span>
145
+ </div>
144
146
  </div>
145
147
 
146
148
  <div class="header-right">
@@ -154,6 +156,24 @@
154
156
  <main class="content-area" id="main-content">
155
157
  <div class="content-layout">
156
158
  <div class="main-content">
159
+ <% if (config.layout?.breadcrumbs !== false && locals.breadcrumbs && breadcrumbs.length > 0) { %>
160
+ <nav aria-label="breadcrumb" class="docmd-breadcrumbs">
161
+ <ol>
162
+ <% breadcrumbs.forEach((crumb, index) => { %>
163
+ <li class="breadcrumb-item <%= index === breadcrumbs.length - 1 ? 'active' : '' %>" <%= index === breadcrumbs.length - 1 ? 'aria-current="page"' : '' %>>
164
+ <% if (crumb.path && index < breadcrumbs.length - 1) { %>
165
+ <a href="<%= relativePathToRoot %><%- crumb.path.startsWith('/') ? crumb.path.substring(1) : crumb.path %>"><%= crumb.title %></a>
166
+ <% } else { %>
167
+ <span><%= crumb.title %></span>
168
+ <% } %>
169
+ <% if (index < breadcrumbs.length - 1) { %>
170
+ <span class="breadcrumb-separator"><%- renderIcon('chevron-right') %></span>
171
+ <% } %>
172
+ </li>
173
+ <% }) %>
174
+ </ol>
175
+ </nav>
176
+ <% } %>
157
177
  <% if (headerConfig?.enabled===false) { %>
158
178
  <h1>
159
179
  <%= pageTitle %>