@barodoc/theme-docs 1.0.1 → 2.0.0
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": "@barodoc/theme-docs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Documentation theme for Barodoc",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lucide-react": "^0.563.0",
|
|
31
31
|
"mermaid": "^11.12.2",
|
|
32
32
|
"tailwind-merge": "^3.4.0",
|
|
33
|
-
"@barodoc/core": "
|
|
33
|
+
"@barodoc/core": "2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"astro": "^5.0.0",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from "virtual:barodoc/config";
|
|
3
|
+
|
|
4
|
+
const announcement = config.announcement;
|
|
5
|
+
const show = !!announcement?.text;
|
|
6
|
+
const dismissible = announcement?.dismissible !== false;
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
{show && (
|
|
10
|
+
<div
|
|
11
|
+
id="site-banner"
|
|
12
|
+
class="banner-bar bg-primary-600 text-white text-sm text-center py-2 px-4 flex items-center justify-center gap-2 relative"
|
|
13
|
+
>
|
|
14
|
+
{announcement.link ? (
|
|
15
|
+
<a href={announcement.link} class="hover:underline font-medium">
|
|
16
|
+
{announcement.text}
|
|
17
|
+
<svg class="inline w-3.5 h-3.5 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
18
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
|
|
19
|
+
</svg>
|
|
20
|
+
</a>
|
|
21
|
+
) : (
|
|
22
|
+
<span class="font-medium">{announcement.text}</span>
|
|
23
|
+
)}
|
|
24
|
+
{dismissible && (
|
|
25
|
+
<button
|
|
26
|
+
id="banner-dismiss"
|
|
27
|
+
class="absolute right-3 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-white/20 transition-colors"
|
|
28
|
+
aria-label="Dismiss banner"
|
|
29
|
+
>
|
|
30
|
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
31
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
32
|
+
</svg>
|
|
33
|
+
</button>
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
<script>
|
|
37
|
+
function initBanner() {
|
|
38
|
+
const banner = document.getElementById('site-banner');
|
|
39
|
+
const dismiss = document.getElementById('banner-dismiss');
|
|
40
|
+
if (!banner) return;
|
|
41
|
+
const key = 'barodoc-banner-dismissed';
|
|
42
|
+
if (localStorage.getItem(key) === banner.textContent?.trim()) {
|
|
43
|
+
banner.style.display = 'none';
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (dismiss) {
|
|
47
|
+
dismiss.addEventListener('click', () => {
|
|
48
|
+
banner.style.display = 'none';
|
|
49
|
+
localStorage.setItem(key, banner.textContent?.trim() || '');
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
initBanner();
|
|
54
|
+
document.addEventListener('astro:page-load', initBanner);
|
|
55
|
+
</script>
|
|
56
|
+
)}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface BreadcrumbItem {
|
|
3
|
+
label: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
items: BreadcrumbItem[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { items } = Astro.props;
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<nav aria-label="Breadcrumb" class="mb-3">
|
|
15
|
+
<ol class="flex flex-wrap items-center gap-1 text-xs text-[var(--color-text-muted)]">
|
|
16
|
+
<li class="flex items-center gap-1">
|
|
17
|
+
<a href="/docs" class="hover:text-[var(--color-text-secondary)] transition-colors">Docs</a>
|
|
18
|
+
</li>
|
|
19
|
+
{items.map((item, i) => (
|
|
20
|
+
<li class="flex items-center gap-1">
|
|
21
|
+
<svg class="w-3 h-3 text-[var(--color-text-muted)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
22
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
|
|
23
|
+
</svg>
|
|
24
|
+
{item.href && i < items.length - 1 ? (
|
|
25
|
+
<a href={item.href} class="hover:text-[var(--color-text-secondary)] transition-colors">{item.label}</a>
|
|
26
|
+
) : (
|
|
27
|
+
<span class="text-[var(--color-text-secondary)]">{item.label}</span>
|
|
28
|
+
)}
|
|
29
|
+
</li>
|
|
30
|
+
))}
|
|
31
|
+
</ol>
|
|
32
|
+
</nav>
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
import ThemeScript from "../components/ThemeScript.astro";
|
|
3
3
|
import { SearchDialog } from "../components/SearchDialog";
|
|
4
|
+
import config from "virtual:barodoc/config";
|
|
4
5
|
import "@barodoc/theme-docs/styles/global.css";
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
title: string;
|
|
8
9
|
description?: string;
|
|
10
|
+
ogImage?: string;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
const { title, description = "Documentation" } = Astro.props;
|
|
13
|
+
const { title, description = "Documentation", ogImage } = Astro.props;
|
|
14
|
+
const siteName = config.name;
|
|
15
|
+
const canonicalUrl = config.site ? new URL(Astro.url.pathname, config.site).href : Astro.url.href;
|
|
16
|
+
const ogImageUrl = ogImage
|
|
17
|
+
? (config.site ? new URL(ogImage, config.site).href : ogImage)
|
|
18
|
+
: undefined;
|
|
12
19
|
---
|
|
13
20
|
|
|
14
21
|
<!doctype html>
|
|
@@ -18,6 +25,22 @@ const { title, description = "Documentation" } = Astro.props;
|
|
|
18
25
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
19
26
|
<meta name="description" content={description} />
|
|
20
27
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
28
|
+
<link rel="canonical" href={canonicalUrl} />
|
|
29
|
+
|
|
30
|
+
<!-- Open Graph -->
|
|
31
|
+
<meta property="og:type" content="article" />
|
|
32
|
+
<meta property="og:title" content={title} />
|
|
33
|
+
<meta property="og:description" content={description} />
|
|
34
|
+
<meta property="og:site_name" content={siteName} />
|
|
35
|
+
<meta property="og:url" content={canonicalUrl} />
|
|
36
|
+
{ogImageUrl && <meta property="og:image" content={ogImageUrl} />}
|
|
37
|
+
|
|
38
|
+
<!-- Twitter Card -->
|
|
39
|
+
<meta name="twitter:card" content={ogImageUrl ? "summary_large_image" : "summary"} />
|
|
40
|
+
<meta name="twitter:title" content={title} />
|
|
41
|
+
<meta name="twitter:description" content={description} />
|
|
42
|
+
{ogImageUrl && <meta name="twitter:image" content={ogImageUrl} />}
|
|
43
|
+
|
|
21
44
|
<title>{title}</title>
|
|
22
45
|
<ThemeScript />
|
|
23
46
|
</head>
|
|
@@ -5,31 +5,46 @@ import Sidebar from "../components/Sidebar.astro";
|
|
|
5
5
|
import TableOfContents from "../components/TableOfContents.astro";
|
|
6
6
|
import MobileNav from "../components/MobileNav.astro";
|
|
7
7
|
import CodeCopy from "../components/CodeCopy.astro";
|
|
8
|
+
import Breadcrumb from "../components/Breadcrumb.astro";
|
|
9
|
+
import Banner from "../components/Banner.astro";
|
|
8
10
|
import { defaultLocale } from "virtual:barodoc/i18n";
|
|
9
11
|
import { getLocaleFromPath } from "@barodoc/core";
|
|
12
|
+
import config from "virtual:barodoc/config";
|
|
10
13
|
|
|
11
14
|
interface PageLink {
|
|
12
15
|
title: string;
|
|
13
16
|
href: string;
|
|
14
17
|
}
|
|
15
18
|
|
|
19
|
+
interface BreadcrumbItem {
|
|
20
|
+
label: string;
|
|
21
|
+
href?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
interface Props {
|
|
17
25
|
title: string;
|
|
18
26
|
description?: string;
|
|
19
27
|
headings?: { depth: number; slug: string; text: string }[];
|
|
20
28
|
prevPage?: PageLink | null;
|
|
21
29
|
nextPage?: PageLink | null;
|
|
30
|
+
editUrl?: string | null;
|
|
31
|
+
lastUpdated?: Date | null;
|
|
32
|
+
breadcrumbs?: BreadcrumbItem[];
|
|
22
33
|
}
|
|
23
34
|
|
|
24
|
-
const { title, description, headings = [], prevPage, nextPage } = Astro.props;
|
|
35
|
+
const { title, description, headings = [], prevPage, nextPage, editUrl, lastUpdated, breadcrumbs = [] } = Astro.props;
|
|
25
36
|
const currentPath = Astro.url.pathname;
|
|
26
37
|
|
|
27
38
|
// Get locale from path
|
|
28
39
|
const i18nConfig = { defaultLocale, locales: [defaultLocale] };
|
|
29
40
|
const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
|
|
41
|
+
|
|
42
|
+
const hasFeedback = config.feedback?.enabled === true;
|
|
43
|
+
const feedbackEndpoint = config.feedback?.endpoint;
|
|
30
44
|
---
|
|
31
45
|
|
|
32
46
|
<BaseLayout title={title} description={description}>
|
|
47
|
+
<Banner />
|
|
33
48
|
<Header currentLocale={currentLocale} currentPath={currentPath} />
|
|
34
49
|
|
|
35
50
|
<!-- Centered container for docs layout -->
|
|
@@ -45,6 +60,7 @@ const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
|
|
|
45
60
|
<!-- Main Content: no min-width on mobile to avoid horizontal scroll -->
|
|
46
61
|
<main class="flex-1 min-w-0 lg:min-w-[650px] max-w-[720px]">
|
|
47
62
|
<div class="px-4 py-6 sm:px-6 sm:py-8 lg:px-8 lg:py-8">
|
|
63
|
+
{breadcrumbs.length > 0 && <Breadcrumb items={breadcrumbs} />}
|
|
48
64
|
<article class="prose prose-gray dark:prose-invert max-w-none min-w-0 overflow-x-auto">
|
|
49
65
|
<slot />
|
|
50
66
|
</article>
|
|
@@ -94,10 +110,41 @@ const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
|
|
|
94
110
|
)}
|
|
95
111
|
|
|
96
112
|
<!-- Page footer -->
|
|
97
|
-
<footer class="mt-6 pt-4 border-t border-[var(--color-border-light)]">
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
<footer class="mt-6 pt-4 border-t border-[var(--color-border-light)] flex flex-col gap-3">
|
|
114
|
+
<div class="flex flex-wrap items-center justify-between gap-2 text-sm text-[var(--color-text-muted)]">
|
|
115
|
+
{lastUpdated && (
|
|
116
|
+
<span>
|
|
117
|
+
Last updated: <time datetime={lastUpdated.toISOString()}>
|
|
118
|
+
{lastUpdated.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" })}
|
|
119
|
+
</time>
|
|
120
|
+
</span>
|
|
121
|
+
)}
|
|
122
|
+
{editUrl && (
|
|
123
|
+
<a
|
|
124
|
+
href={editUrl}
|
|
125
|
+
target="_blank"
|
|
126
|
+
rel="noopener noreferrer"
|
|
127
|
+
class="inline-flex items-center gap-1 text-primary-600 dark:text-primary-400 hover:underline"
|
|
128
|
+
>
|
|
129
|
+
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
130
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
|
131
|
+
</svg>
|
|
132
|
+
Edit this page
|
|
133
|
+
</a>
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
{hasFeedback && (
|
|
137
|
+
<div class="doc-feedback flex items-center gap-3 text-sm text-[var(--color-text-muted)]" data-endpoint={feedbackEndpoint}>
|
|
138
|
+
<span>Was this page helpful?</span>
|
|
139
|
+
<button type="button" class="feedback-btn inline-flex items-center gap-1 px-2 py-1 rounded border border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] transition-colors" data-value="yes" aria-label="Yes">
|
|
140
|
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 9V5a3 3 0 00-3-3l-4 9v11h11.28a2 2 0 002-1.7l1.38-9a2 2 0 00-2-2.3H14z" /></svg>
|
|
141
|
+
</button>
|
|
142
|
+
<button type="button" class="feedback-btn inline-flex items-center gap-1 px-2 py-1 rounded border border-[var(--color-border)] hover:bg-[var(--color-bg-secondary)] transition-colors" data-value="no" aria-label="No">
|
|
143
|
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 15v3.586a1 1 0 01-.293.707l-2 2A1 1 0 016 20.586V15m4 0h5.17a2 2 0 001.98-1.742l1.08-7.56A1 1 0 0017.242 4.5H10m0 10.5V4.5m0 0H7.5A2.5 2.5 0 005 7v3" /></svg>
|
|
144
|
+
</button>
|
|
145
|
+
<span class="feedback-thanks hidden text-green-600 dark:text-green-400">Thanks for your feedback!</span>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
101
148
|
</footer>
|
|
102
149
|
</div>
|
|
103
150
|
</main>
|
|
@@ -118,4 +165,30 @@ const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
|
|
|
118
165
|
|
|
119
166
|
<!-- Code copy functionality -->
|
|
120
167
|
<CodeCopy />
|
|
168
|
+
|
|
169
|
+
{hasFeedback && (
|
|
170
|
+
<script>
|
|
171
|
+
function initFeedback() {
|
|
172
|
+
document.querySelectorAll('.doc-feedback').forEach((el) => {
|
|
173
|
+
if (el.hasAttribute('data-init')) return;
|
|
174
|
+
el.setAttribute('data-init', 'true');
|
|
175
|
+
const endpoint = el.getAttribute('data-endpoint');
|
|
176
|
+
const thanks = el.querySelector('.feedback-thanks');
|
|
177
|
+
el.querySelectorAll('.feedback-btn').forEach((btn) => {
|
|
178
|
+
btn.addEventListener('click', async () => {
|
|
179
|
+
const value = btn.getAttribute('data-value');
|
|
180
|
+
const page = window.location.pathname;
|
|
181
|
+
el.querySelectorAll('.feedback-btn').forEach((b: any) => b.disabled = true);
|
|
182
|
+
if (thanks) thanks.classList.remove('hidden');
|
|
183
|
+
if (endpoint) {
|
|
184
|
+
try { await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ page, value }) }); } catch {}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
initFeedback();
|
|
191
|
+
document.addEventListener('astro:page-load', initFeedback);
|
|
192
|
+
</script>
|
|
193
|
+
)}
|
|
121
194
|
</BaseLayout>
|
|
@@ -89,6 +89,28 @@ const nextPage = currentIndex < allPages.length - 1
|
|
|
89
89
|
: null;
|
|
90
90
|
|
|
91
91
|
const category = findCategory(cleanSlug);
|
|
92
|
+
|
|
93
|
+
// Edit link
|
|
94
|
+
const editBaseUrl = config.editLink?.baseUrl;
|
|
95
|
+
const editUrl = editBaseUrl
|
|
96
|
+
? `${editBaseUrl.replace(/\/$/, "")}/${doc.id}`
|
|
97
|
+
: null;
|
|
98
|
+
|
|
99
|
+
// Last updated: use file modification if available
|
|
100
|
+
let lastUpdated: Date | null = null;
|
|
101
|
+
if (config.lastUpdated) {
|
|
102
|
+
const mod = (doc.data as Record<string, unknown>).lastUpdated;
|
|
103
|
+
if (mod instanceof Date) {
|
|
104
|
+
lastUpdated = mod;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Breadcrumbs: [Group, Page Title]
|
|
109
|
+
const breadcrumbs: { label: string; href?: string }[] = [];
|
|
110
|
+
if (category) {
|
|
111
|
+
breadcrumbs.push({ label: category });
|
|
112
|
+
}
|
|
113
|
+
breadcrumbs.push({ label: doc.data.title });
|
|
92
114
|
---
|
|
93
115
|
|
|
94
116
|
<DocsLayout
|
|
@@ -97,6 +119,9 @@ const category = findCategory(cleanSlug);
|
|
|
97
119
|
headings={headings}
|
|
98
120
|
prevPage={prevPage}
|
|
99
121
|
nextPage={nextPage}
|
|
122
|
+
editUrl={editUrl}
|
|
123
|
+
lastUpdated={lastUpdated}
|
|
124
|
+
breadcrumbs={breadcrumbs}
|
|
100
125
|
>
|
|
101
126
|
{category && (
|
|
102
127
|
<p class="text-xs font-medium uppercase tracking-wider text-primary-600 dark:text-primary-400 mb-2">
|