@barodoc/theme-docs 6.1.0 → 7.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": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "Documentation theme for Barodoc",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,7 +34,7 @@
34
34
  "rehype-katex": "^7.0.1",
35
35
  "remark-math": "^6.0.0",
36
36
  "tailwind-merge": "^3.4.0",
37
- "@barodoc/core": "6.0.0"
37
+ "@barodoc/core": "7.0.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "astro": "^5.0.0",
@@ -27,11 +27,21 @@ if (filePath) {
27
27
  for (const line of raw.split("\n")) {
28
28
  const [name, email] = line.split("|");
29
29
  if (!name || seen.has(email)) continue;
30
- const hash = email.trim().toLowerCase();
31
- seen.set(email, {
32
- name: name.trim(),
33
- email: email.trim(),
34
- avatarUrl: `https://gravatar.com/avatar/${await computeHash(hash)}?s=64&d=mp`,
30
+
31
+ const trimmedEmail = email.trim();
32
+ const trimmedName = name.trim();
33
+
34
+ const noreplyMatch = trimmedEmail.match(
35
+ /^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/
36
+ );
37
+ const avatarUrl = noreplyMatch
38
+ ? `https://github.com/${noreplyMatch[2]}.png?size=64`
39
+ : `https://gravatar.com/avatar/${await computeHash(trimmedEmail.toLowerCase())}?s=64&d=mp`;
40
+
41
+ seen.set(trimmedEmail, {
42
+ name: trimmedName,
43
+ email: trimmedEmail,
44
+ avatarUrl,
35
45
  });
36
46
  }
37
47
  contributors = Array.from(seen.values());
@@ -55,17 +65,23 @@ async function computeHash(input: string): Promise<string> {
55
65
  <div class="bd-contributors">
56
66
  <span class="bd-contributors-label">Contributors</span>
57
67
  <div class="bd-contributors-avatars">
58
- {contributors.map((c) => (
59
- <img
60
- src={c.avatarUrl}
61
- alt={c.name}
62
- title={c.name}
63
- class="bd-contributor-avatar"
64
- loading="lazy"
65
- width="28"
66
- height="28"
67
- />
68
- ))}
68
+ <img
69
+ src={contributors[0].avatarUrl}
70
+ alt={contributors[0].name}
71
+ title={contributors[0].name}
72
+ class="bd-contributor-avatar"
73
+ loading="lazy"
74
+ width="28"
75
+ height="28"
76
+ />
77
+ {contributors.length > 1 && (
78
+ <span
79
+ class="bd-contributor-count"
80
+ title={contributors.slice(1).map((c) => c.name).join(", ")}
81
+ >
82
+ +{contributors.length - 1}
83
+ </span>
84
+ )}
69
85
  </div>
70
86
  </div>
71
87
  )}
@@ -10,9 +10,15 @@ import {
10
10
  } from "./ui/tooltip";
11
11
  import { cn } from "../lib/utils";
12
12
 
13
+ interface TabItem {
14
+ label: string;
15
+ href: string;
16
+ }
17
+
13
18
  interface DocHeaderProps {
14
19
  siteName: string;
15
20
  logo?: string;
21
+ tabs?: TabItem[];
16
22
  githubUrl?: string;
17
23
  hasMultipleLocales?: boolean;
18
24
  currentLocale?: string;
@@ -46,6 +52,7 @@ function getLocalizedUrl(
46
52
  export function DocHeader({
47
53
  siteName,
48
54
  logo,
55
+ tabs = [],
49
56
  githubUrl,
50
57
  hasMultipleLocales,
51
58
  currentLocale = "en",
@@ -92,7 +99,7 @@ export function DocHeader({
92
99
  <TooltipProvider>
93
100
  <header className="sticky top-0 z-50 w-full min-w-0 border-b border-[var(--bd-border)] bg-[var(--bd-bg)]/95 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--bd-bg)]/80">
94
101
  <div className="flex h-14 items-center justify-between gap-2 px-4 sm:px-6 max-w-[1280px] mx-auto min-w-0">
95
- {/* Logo */}
102
+ {/* Logo + Tabs */}
96
103
  <div className="flex items-center gap-6 min-w-0 shrink">
97
104
  <a
98
105
  href="/"
@@ -101,6 +108,27 @@ export function DocHeader({
101
108
  {logo && <img src={logo} alt={siteName} className="h-7 w-7 shrink-0" />}
102
109
  <span className="text-[15px] tracking-tight truncate">{siteName}</span>
103
110
  </a>
111
+ {tabs.length > 0 && (
112
+ <nav className="hidden md:flex items-center gap-1">
113
+ {tabs.map((tab) => {
114
+ const isActive = currentPath === tab.href || currentPath.startsWith(tab.href + "/");
115
+ return (
116
+ <a
117
+ key={tab.href}
118
+ href={tab.href}
119
+ className={cn(
120
+ "px-3 py-1.5 text-[13px] font-medium rounded-lg transition-colors",
121
+ isActive
122
+ ? "text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-950/50"
123
+ : "text-[var(--bd-text-secondary)] hover:text-[var(--bd-text)] hover:bg-[var(--bd-bg-subtle)]"
124
+ )}
125
+ >
126
+ {tab.label}
127
+ </a>
128
+ );
129
+ })}
130
+ </nav>
131
+ )}
104
132
  </div>
105
133
 
106
134
  {/* Right side actions */}
@@ -18,6 +18,7 @@ const localeLabels: Record<string, string> = config.i18n?.labels || {};
18
18
  client:load
19
19
  siteName={config.name}
20
20
  logo={config.logo}
21
+ tabs={config.tabs}
21
22
  githubUrl={config.topbar?.github}
22
23
  hasMultipleLocales={hasMultipleLocales}
23
24
  currentLocale={currentLocale}
@@ -58,4 +58,6 @@ const groups = config.navigation.map((group) => ({
58
58
  groups={groups}
59
59
  siteName={config.name}
60
60
  logo={config.logo}
61
+ tabs={config.tabs}
62
+ currentPath={currentPath}
61
63
  />
@@ -21,13 +21,20 @@ interface NavGroup {
21
21
  defaultOpen?: boolean;
22
22
  }
23
23
 
24
+ interface TabItem {
25
+ label: string;
26
+ href: string;
27
+ }
28
+
24
29
  interface MobileNavSheetProps {
25
30
  groups: NavGroup[];
26
31
  siteName: string;
27
32
  logo?: string;
33
+ tabs?: TabItem[];
34
+ currentPath?: string;
28
35
  }
29
36
 
30
- export function MobileNavSheet({ groups, siteName, logo }: MobileNavSheetProps) {
37
+ export function MobileNavSheet({ groups, siteName, logo, tabs = [], currentPath = "" }: MobileNavSheetProps) {
31
38
  const [open, setOpen] = React.useState(false);
32
39
 
33
40
  React.useEffect(() => {
@@ -61,6 +68,27 @@ export function MobileNavSheet({ groups, siteName, logo }: MobileNavSheetProps)
61
68
  </SheetTitle>
62
69
  </SheetHeader>
63
70
  <ScrollArea className="h-[calc(100vh-65px)]">
71
+ {tabs.length > 0 && (
72
+ <div className="px-4 pt-4 pb-2 flex flex-col gap-1 border-b border-[var(--bd-border)]">
73
+ {tabs.map((tab) => {
74
+ const isActive = currentPath === tab.href || currentPath.startsWith(tab.href + "/");
75
+ return (
76
+ <a
77
+ key={tab.href}
78
+ href={tab.href}
79
+ className={cn(
80
+ "px-3 py-2 text-sm font-medium rounded-lg transition-colors",
81
+ isActive
82
+ ? "text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-950/50"
83
+ : "text-[var(--bd-text-secondary)] hover:text-[var(--bd-text)] hover:bg-[var(--bd-bg-subtle)]"
84
+ )}
85
+ >
86
+ {tab.label}
87
+ </a>
88
+ );
89
+ })}
90
+ </div>
91
+ )}
64
92
  <div className="px-2 py-4">
65
93
  <DocsSidebar groups={groups} />
66
94
  </div>
@@ -2,6 +2,7 @@
2
2
  import BaseLayout from "./BaseLayout.astro";
3
3
  import Header from "../components/Header.astro";
4
4
  import Banner from "../components/Banner.astro";
5
+ import CodeCopy from "../components/CodeCopy.astro";
5
6
  import { defaultLocale } from "virtual:barodoc/i18n";
6
7
  import { getLocaleFromPath } from "@barodoc/core";
7
8
 
@@ -10,12 +11,13 @@ interface Props {
10
11
  description?: string;
11
12
  date?: Date;
12
13
  author?: string;
14
+ avatar?: string;
13
15
  image?: string;
14
16
  tags?: string[];
15
17
  readingTime?: string;
16
18
  }
17
19
 
18
- const { title, description, date, author, image, tags = [], readingTime } = Astro.props;
20
+ const { title, description, date, author, avatar, image, tags = [], readingTime } = Astro.props;
19
21
  const currentPath = Astro.url.pathname;
20
22
  const i18nConfig = { defaultLocale, locales: [defaultLocale] };
21
23
  const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
@@ -47,7 +49,18 @@ const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
47
49
  </p>
48
50
  )}
49
51
  <div class="mt-4 flex items-center gap-3 text-sm text-[var(--bd-text-muted)]">
50
- {author && <span>{author}</span>}
52
+ {author && (
53
+ <span class="flex items-center gap-2">
54
+ {avatar && (
55
+ <img
56
+ src={avatar}
57
+ alt={author}
58
+ class="w-6 h-6 rounded-full object-cover ring-1 ring-[var(--bd-border)]"
59
+ />
60
+ )}
61
+ <span>{author}</span>
62
+ </span>
63
+ )}
51
64
  {author && date && <span class="text-[var(--bd-border)]">&middot;</span>}
52
65
  {date && (
53
66
  <time datetime={date.toISOString()}>
@@ -75,6 +88,7 @@ const currentLocale = getLocaleFromPath(currentPath, i18nConfig);
75
88
  <div class="prose prose-gray dark:prose-invert max-w-none">
76
89
  <slot />
77
90
  </div>
91
+ <CodeCopy />
78
92
 
79
93
  <!-- Back to blog -->
80
94
  <div class="mt-12 pt-8 border-t border-[var(--bd-border)]">
@@ -31,6 +31,7 @@ const readTime = readingTime(post.body ?? "");
31
31
  description={post.data.description || post.data.excerpt}
32
32
  date={post.data.date ? new Date(post.data.date) : undefined}
33
33
  author={post.data.author}
34
+ avatar={post.data.avatar}
34
35
  image={post.data.image}
35
36
  tags={post.data.tags}
36
37
  readingTime={readTime.text}
@@ -74,7 +74,18 @@ const sortedPosts = posts.sort((a, b) => {
74
74
  </p>
75
75
  )}
76
76
  <div class="mt-auto pt-2 flex items-center gap-2 text-xs text-[var(--bd-text-muted)]">
77
- {post.data.author && <span>{post.data.author}</span>}
77
+ {post.data.author && (
78
+ <span class="flex items-center gap-1.5">
79
+ {post.data.avatar && (
80
+ <img
81
+ src={post.data.avatar}
82
+ alt={post.data.author}
83
+ class="w-4 h-4 rounded-full object-cover"
84
+ />
85
+ )}
86
+ <span>{post.data.author}</span>
87
+ </span>
88
+ )}
78
89
  {post.data.author && post.data.date && <span>&middot;</span>}
79
90
  {post.data.date && (
80
91
  <time datetime={new Date(post.data.date).toISOString()}>
@@ -125,7 +125,7 @@ breadcrumbs.push({ label: doc.data.title });
125
125
  lastUpdated={lastUpdated}
126
126
  breadcrumbs={breadcrumbs}
127
127
  readingTime={readTime.text}
128
- filePath={doc.id}
128
+ filePath={`src/content/docs/${doc.id}`}
129
129
  >
130
130
  {category && (
131
131
  <p class="text-xs font-semibold uppercase tracking-widest text-primary-600 dark:text-primary-400 mb-3">
@@ -43,10 +43,24 @@ const features = [
43
43
  <header class="sticky top-0 z-50 border-b border-[var(--bd-border)] bg-[var(--bd-bg)]/95 backdrop-blur-md">
44
44
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
45
45
  <div class="flex h-16 items-center justify-between">
46
- <a href="/" class="flex items-center gap-2.5 font-semibold text-[var(--bd-text)]">
47
- {config.logo && <img src={config.logo} alt={config.name} class="h-7 w-7" />}
48
- <span class="text-lg">{config.name}</span>
49
- </a>
46
+ <div class="flex items-center gap-6">
47
+ <a href="/" class="flex items-center gap-2.5 font-semibold text-[var(--bd-text)]">
48
+ {config.logo && <img src={config.logo} alt={config.name} class="h-7 w-7" />}
49
+ <span class="text-lg">{config.name}</span>
50
+ </a>
51
+ {config.tabs && config.tabs.length > 0 && (
52
+ <nav class="hidden md:flex items-center gap-1">
53
+ {config.tabs.map((tab: { label: string; href: string }) => (
54
+ <a
55
+ href={tab.href}
56
+ class="px-3 py-1.5 text-sm font-medium rounded-lg text-[var(--bd-text-secondary)] hover:text-[var(--bd-text)] hover:bg-[var(--bd-bg-subtle)] transition-colors"
57
+ >
58
+ {tab.label}
59
+ </a>
60
+ ))}
61
+ </nav>
62
+ )}
63
+ </div>
50
64
  <div class="flex items-center gap-2">
51
65
  {config.topbar?.github && (
52
66
  <a
@@ -983,6 +983,22 @@
983
983
  margin-left: 0;
984
984
  }
985
985
 
986
+ .bd-contributor-count {
987
+ display: inline-flex;
988
+ align-items: center;
989
+ justify-content: center;
990
+ width: 1.75rem;
991
+ height: 1.75rem;
992
+ border-radius: 9999px;
993
+ border: 2px solid var(--bd-bg);
994
+ margin-left: -0.375rem;
995
+ background: var(--bd-bg-subtle);
996
+ color: var(--bd-text-muted);
997
+ font-size: 0.6875rem;
998
+ font-weight: 600;
999
+ cursor: default;
1000
+ }
1001
+
986
1002
  /* ==========================================================================
987
1003
  Version Switcher
988
1004
  ========================================================================== */