@verbb/vitepress-theme 1.0.0 → 1.0.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.
- package/package.json +7 -2
- package/src/Layout.vue +135 -88
- package/src/custom.css +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbb/vitepress-theme",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Shared VitePress theme (layout, sidebar, local search) for Verbb documentation sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"release:patch": "npm version patch && npm publish --access public && git push origin main",
|
|
23
|
+
"release:minor": "npm version minor && npm publish --access public && git push origin main",
|
|
24
|
+
"release:major": "npm version major && npm publish --access public && git push origin main"
|
|
25
|
+
},
|
|
21
26
|
"peerDependencies": {
|
|
22
27
|
"vitepress": "^1.6.4",
|
|
23
28
|
"vue": "^3.5.33"
|
|
@@ -27,6 +32,6 @@
|
|
|
27
32
|
"tailwindcss": "^4.2.4",
|
|
28
33
|
"typescript": "^6.0.3",
|
|
29
34
|
"vitepress": "^1.6.4",
|
|
30
|
-
|
|
35
|
+
"vue": "^3.5.33"
|
|
31
36
|
}
|
|
32
37
|
}
|
package/src/Layout.vue
CHANGED
|
@@ -10,6 +10,7 @@ import { openDocsSearch } from './search';
|
|
|
10
10
|
import { hasActiveSidebarItem, isActivePath, type SidebarGroup, type SidebarItem, useCloseSidebarOnEscape, useDocsSidebar } from './sidebar';
|
|
11
11
|
|
|
12
12
|
type DocsThemeOptions = {
|
|
13
|
+
homeLink?: string;
|
|
13
14
|
primary?: string;
|
|
14
15
|
primaryStrong?: string;
|
|
15
16
|
primarySoft?: string;
|
|
@@ -78,6 +79,11 @@ const siteTitle = computed(() => {
|
|
|
78
79
|
|
|
79
80
|
return site.value.title;
|
|
80
81
|
});
|
|
82
|
+
const homeHref = computed(() => {
|
|
83
|
+
const configuredHomeLink = (theme.value as typeof theme.value & { docsTheme?: DocsThemeOptions; }).docsTheme?.homeLink;
|
|
84
|
+
|
|
85
|
+
return configuredHomeLink || site.value.base || '/';
|
|
86
|
+
});
|
|
81
87
|
const socialLinks = computed(() => theme.value.socialLinks ?? []);
|
|
82
88
|
const currentSidebarGroup = computed<SidebarGroup | null>(() => {
|
|
83
89
|
return sidebarGroups.value.find((group) => {
|
|
@@ -181,12 +187,18 @@ function flattenNavItems(items: DocsNavItem[]): DocsNavLink[] {
|
|
|
181
187
|
|
|
182
188
|
function normalizeRoutePath(path: string) {
|
|
183
189
|
const sanitizedPath = decodeURI(path).split(/[?#]/, 1)[0] || '/';
|
|
190
|
+
const base = site.value.base && site.value.base !== '/'
|
|
191
|
+
? site.value.base.replace(/\/+$/, '')
|
|
192
|
+
: '';
|
|
193
|
+
const baseRelativePath = base && sanitizedPath.startsWith(`${base}/`)
|
|
194
|
+
? sanitizedPath.slice(base.length)
|
|
195
|
+
: sanitizedPath;
|
|
184
196
|
|
|
185
|
-
if (
|
|
197
|
+
if (baseRelativePath === '/') {
|
|
186
198
|
return '/';
|
|
187
199
|
}
|
|
188
200
|
|
|
189
|
-
const withoutIndex =
|
|
201
|
+
const withoutIndex = baseRelativePath.replace(/\/index(?:\.html)?$/, '/');
|
|
190
202
|
const withoutExtension = withoutIndex.replace(/\.html$/, '');
|
|
191
203
|
|
|
192
204
|
return withoutExtension === '/'
|
|
@@ -688,8 +700,21 @@ onBeforeUnmount(() => {
|
|
|
688
700
|
<DocsSearchProvider v-if="hasSearch" />
|
|
689
701
|
<div class="max-lg:contents lg:flex lg:w-full" data-docs-theme="almond" :style="docsThemeStyle">
|
|
690
702
|
<div class="max-lg:contents lg:flex-1 lg:min-w-0 lg:overflow-x-clip">
|
|
691
|
-
|
|
692
|
-
|
|
703
|
+
<!--
|
|
704
|
+
When the mobile drawer is open, disable hits on the whole navbar.
|
|
705
|
+
Inner fade already uses pointer-events-none, but the header chrome
|
|
706
|
+
wrappers still sit at z-30 above the close control and steal clicks.
|
|
707
|
+
-->
|
|
708
|
+
<header
|
|
709
|
+
id="navbar"
|
|
710
|
+
class="peer fixed top-0 z-30 w-full"
|
|
711
|
+
:class="isOpen ? 'max-lg:pointer-events-none' : ''"
|
|
712
|
+
>
|
|
713
|
+
<!--
|
|
714
|
+
Mobile inset matches the content card's border edge (grid px-2 = 8px),
|
|
715
|
+
not the prose column — logo / switcher / icons line up with the box.
|
|
716
|
+
-->
|
|
717
|
+
<div class="relative z-10 mx-auto max-w-[96rem] px-4 max-lg:px-3">
|
|
693
718
|
<div class="relative">
|
|
694
719
|
<div
|
|
695
720
|
class="transition-opacity duration-200"
|
|
@@ -697,14 +722,67 @@ onBeforeUnmount(() => {
|
|
|
697
722
|
>
|
|
698
723
|
<div class="lg:hidden">
|
|
699
724
|
<div class="flex h-14 items-center justify-between gap-3">
|
|
700
|
-
<
|
|
701
|
-
<
|
|
702
|
-
|
|
703
|
-
|
|
725
|
+
<div class="flex min-w-0 flex-1 items-center gap-2.5">
|
|
726
|
+
<a :href="homeHref" class="flex min-w-0 shrink items-center gap-3 select-none">
|
|
727
|
+
<img v-if="logoSrc" :src="logoSrc" alt="" class="relative block h-6 w-auto max-w-[156px] shrink-0 object-contain" />
|
|
728
|
+
<div v-if="!logoSrc" class="min-w-0 truncate text-[15px] font-semibold tracking-[-0.01em] text-slate-900">
|
|
729
|
+
{{ siteTitle }}
|
|
730
|
+
</div>
|
|
731
|
+
</a>
|
|
732
|
+
|
|
733
|
+
<!--
|
|
734
|
+
Keep the section switcher on the logo row on mobile —
|
|
735
|
+
a second sticky row costs too much viewport height.
|
|
736
|
+
-->
|
|
737
|
+
<div
|
|
738
|
+
v-if="topNavLinks.length"
|
|
739
|
+
ref="topNavRootMobile"
|
|
740
|
+
class="relative min-w-0 shrink"
|
|
741
|
+
>
|
|
742
|
+
<button
|
|
743
|
+
type="button"
|
|
744
|
+
class="inline-flex max-w-full items-center gap-1.5 rounded-xl border border-slate-200/80 bg-white/80 py-1.5 pl-2.5 pr-2 text-sm font-medium text-slate-800"
|
|
745
|
+
:aria-expanded="topNavMenuMobileOpen"
|
|
746
|
+
aria-haspopup="listbox"
|
|
747
|
+
aria-label="Documentation section"
|
|
748
|
+
@click.stop="toggleTopNavMenuMobile"
|
|
749
|
+
>
|
|
750
|
+
<span class="min-w-0 truncate">{{ activeTopNavLabel }}</span>
|
|
751
|
+
<svg
|
|
752
|
+
class="h-4 w-4 shrink-0 text-slate-500 transition-transform"
|
|
753
|
+
:class="topNavMenuMobileOpen ? 'rotate-180' : ''"
|
|
754
|
+
viewBox="0 0 20 20"
|
|
755
|
+
fill="none"
|
|
756
|
+
aria-hidden="true"
|
|
757
|
+
>
|
|
758
|
+
<path d="M5 7.5L10 12.5L15 7.5" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
|
|
759
|
+
</svg>
|
|
760
|
+
</button>
|
|
761
|
+
<div
|
|
762
|
+
v-if="topNavMenuMobileOpen"
|
|
763
|
+
class="absolute left-0 top-full z-[100] mt-1 min-w-[12rem] max-w-[min(100vw-2rem,22rem)] rounded-xl border border-slate-200/80 bg-white py-1 shadow-lg"
|
|
764
|
+
role="listbox"
|
|
765
|
+
:aria-label="`${activeTopNavLabel} options`"
|
|
766
|
+
>
|
|
767
|
+
<a
|
|
768
|
+
v-for="item in topNavLinks"
|
|
769
|
+
:key="item.link"
|
|
770
|
+
:href="withBase(item.link)"
|
|
771
|
+
role="option"
|
|
772
|
+
class="block truncate px-3 py-2 text-sm transition"
|
|
773
|
+
:class="isTopNavLinkActive(item)
|
|
774
|
+
? 'bg-docs-primary-soft font-medium text-docs-primary-strong'
|
|
775
|
+
: 'text-slate-700 hover:bg-slate-50'"
|
|
776
|
+
:aria-selected="isTopNavLinkActive(item)"
|
|
777
|
+
@click="closeTopNavMenus"
|
|
778
|
+
>
|
|
779
|
+
{{ item.text }}
|
|
780
|
+
</a>
|
|
781
|
+
</div>
|
|
704
782
|
</div>
|
|
705
|
-
</
|
|
783
|
+
</div>
|
|
706
784
|
|
|
707
|
-
<div class="flex items-center gap-1.5">
|
|
785
|
+
<div class="-mr-2 flex shrink-0 items-center gap-1.5">
|
|
708
786
|
<button
|
|
709
787
|
v-if="hasSearch"
|
|
710
788
|
type="button"
|
|
@@ -740,53 +818,10 @@ onBeforeUnmount(() => {
|
|
|
740
818
|
</div>
|
|
741
819
|
</div>
|
|
742
820
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
>
|
|
748
|
-
<button
|
|
749
|
-
type="button"
|
|
750
|
-
class="flex w-full items-center justify-between gap-2 rounded-lg border border-slate-200/80 bg-white/80 px-3 py-2 text-left text-sm font-medium text-slate-800"
|
|
751
|
-
:aria-expanded="topNavMenuMobileOpen"
|
|
752
|
-
aria-haspopup="listbox"
|
|
753
|
-
aria-label="Documentation section"
|
|
754
|
-
@click.stop="toggleTopNavMenuMobile"
|
|
755
|
-
>
|
|
756
|
-
<span class="min-w-0 truncate">{{ activeTopNavLabel }}</span>
|
|
757
|
-
<svg
|
|
758
|
-
class="h-4 w-4 shrink-0 text-slate-500 transition-transform"
|
|
759
|
-
:class="topNavMenuMobileOpen ? 'rotate-180' : ''"
|
|
760
|
-
viewBox="0 0 20 20"
|
|
761
|
-
fill="none"
|
|
762
|
-
aria-hidden="true"
|
|
763
|
-
>
|
|
764
|
-
<path d="M5 7.5L10 12.5L15 7.5" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" />
|
|
765
|
-
</svg>
|
|
766
|
-
</button>
|
|
767
|
-
<div
|
|
768
|
-
v-if="topNavMenuMobileOpen"
|
|
769
|
-
class="absolute left-1 right-1 top-full z-[100] mt-1 max-h-[min(60vh,24rem)] overflow-y-auto rounded-xl border border-slate-200/80 bg-white py-1 shadow-lg"
|
|
770
|
-
role="listbox"
|
|
771
|
-
:aria-label="`${activeTopNavLabel} options`"
|
|
772
|
-
>
|
|
773
|
-
<a
|
|
774
|
-
v-for="item in topNavLinks"
|
|
775
|
-
:key="item.link"
|
|
776
|
-
:href="withBase(item.link)"
|
|
777
|
-
role="option"
|
|
778
|
-
class="block truncate px-3 py-2 text-sm transition"
|
|
779
|
-
:class="isTopNavLinkActive(item)
|
|
780
|
-
? 'bg-docs-primary-soft font-medium text-docs-primary-strong'
|
|
781
|
-
: 'text-slate-700 hover:bg-slate-50'"
|
|
782
|
-
:aria-selected="isTopNavLinkActive(item)"
|
|
783
|
-
@click="closeTopNavMenus"
|
|
784
|
-
>
|
|
785
|
-
{{ item.text }}
|
|
786
|
-
</a>
|
|
787
|
-
</div>
|
|
788
|
-
</div>
|
|
789
|
-
|
|
821
|
+
<!--
|
|
822
|
+
Second row: page menu + breadcrumb. Lives in the fixed
|
|
823
|
+
header (not the scrolling card) so it stays put on scroll.
|
|
824
|
+
-->
|
|
790
825
|
<button
|
|
791
826
|
v-if="hasSidebar"
|
|
792
827
|
type="button"
|
|
@@ -818,7 +853,7 @@ onBeforeUnmount(() => {
|
|
|
818
853
|
|
|
819
854
|
<div class="relative hidden h-14 min-w-0 flex-1 items-center gap-x-4 lg:flex lg:border-none">
|
|
820
855
|
<div class="flex min-w-0 flex-1 items-center gap-x-4">
|
|
821
|
-
<a href="
|
|
856
|
+
<a :href="homeHref" class="flex min-w-0 items-center gap-3 select-none">
|
|
822
857
|
<img v-if="logoSrc" :src="logoSrc" alt="" class="relative block h-6 w-auto max-w-[156px] shrink-0 object-contain" />
|
|
823
858
|
<div v-if="!logoSrc" class="min-w-0 truncate text-[15px] font-semibold tracking-[-0.01em] text-slate-900">
|
|
824
859
|
{{ siteTitle }}
|
|
@@ -873,7 +908,7 @@ onBeforeUnmount(() => {
|
|
|
873
908
|
</div>
|
|
874
909
|
</div>
|
|
875
910
|
|
|
876
|
-
<div class="flex items-center gap-4">
|
|
911
|
+
<div class="-mr-2 flex items-center gap-4">
|
|
877
912
|
<div class="flex items-center gap-2">
|
|
878
913
|
<a
|
|
879
914
|
v-for="link in socialLinks"
|
|
@@ -902,41 +937,53 @@ onBeforeUnmount(() => {
|
|
|
902
937
|
</div>
|
|
903
938
|
</header>
|
|
904
939
|
|
|
940
|
+
<!--
|
|
941
|
+
Mobile sticky chrome is two h-14 rows (logo/switcher/icons + page menu),
|
|
942
|
+
so the content shell drops 7rem; desktop keeps its single 3.5rem bar.
|
|
943
|
+
-->
|
|
905
944
|
<div class="scroll-mt-[var(--scroll-mt)] fixed top-[7rem] w-full pb-2 pt-0 lg:top-[3.5rem]">
|
|
945
|
+
<!--
|
|
946
|
+
Own stacking context above the navbar (z-30). Child z-index alone
|
|
947
|
+
was trapped under the header because this content shell is z-auto.
|
|
948
|
+
-->
|
|
906
949
|
<div
|
|
907
950
|
v-if="hasSidebar"
|
|
908
|
-
class="fixed inset-0 z-40
|
|
909
|
-
:class="isOpen ? '
|
|
910
|
-
|
|
911
|
-
/>
|
|
912
|
-
|
|
913
|
-
<button
|
|
914
|
-
v-if="hasSidebar"
|
|
915
|
-
type="button"
|
|
916
|
-
class="fixed right-4 top-5 z-[60] inline-flex h-11 w-11 items-center justify-center rounded-full border border-white/70 bg-white/95 text-slate-500 shadow-[0_8px_24px_rgba(15,23,42,0.16)] backdrop-blur transition duration-300 lg:hidden"
|
|
917
|
-
:class="isOpen ? 'pointer-events-auto opacity-100 scale-100' : 'pointer-events-none opacity-0 scale-95'"
|
|
918
|
-
aria-label="Close navigation menu"
|
|
919
|
-
@click="close"
|
|
920
|
-
>
|
|
921
|
-
<svg viewBox="0 0 20 20" fill="none" class="h-5 w-5" aria-hidden="true">
|
|
922
|
-
<path d="M5 5L15 15M15 5L5 15" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
923
|
-
</svg>
|
|
924
|
-
</button>
|
|
925
|
-
|
|
926
|
-
<aside
|
|
927
|
-
v-if="hasSidebar"
|
|
928
|
-
class="fixed inset-y-0 left-0 z-50 w-[min(22rem,calc(100vw-2.5rem))] max-w-full overflow-y-auto overscroll-contain border-r border-slate-200/80 bg-white shadow-[0_28px_90px_rgba(15,23,42,0.22)] transition-transform duration-300 lg:hidden"
|
|
929
|
-
:class="isOpen ? 'translate-x-0' : '-translate-x-[105%]'"
|
|
951
|
+
class="fixed inset-0 z-40 lg:hidden"
|
|
952
|
+
:class="isOpen ? '' : 'pointer-events-none'"
|
|
953
|
+
:aria-hidden="isOpen ? undefined : 'true'"
|
|
930
954
|
>
|
|
931
|
-
<
|
|
932
|
-
|
|
933
|
-
:
|
|
934
|
-
@
|
|
955
|
+
<div
|
|
956
|
+
class="absolute inset-0 bg-slate-950/40 backdrop-blur-md transition-opacity duration-300"
|
|
957
|
+
:class="isOpen ? 'opacity-100' : 'opacity-0'"
|
|
958
|
+
@click="close"
|
|
935
959
|
/>
|
|
936
|
-
|
|
960
|
+
|
|
961
|
+
<button
|
|
962
|
+
type="button"
|
|
963
|
+
class="absolute right-4 top-5 inline-flex h-11 w-11 items-center justify-center rounded-full border border-white/70 bg-white/95 text-slate-500 shadow-[0_8px_24px_rgba(15,23,42,0.16)] transition duration-300"
|
|
964
|
+
:class="isOpen ? 'opacity-100 scale-100' : 'pointer-events-none opacity-0 scale-95'"
|
|
965
|
+
aria-label="Close navigation menu"
|
|
966
|
+
@click="close"
|
|
967
|
+
>
|
|
968
|
+
<svg viewBox="0 0 20 20" fill="none" class="h-5 w-5" aria-hidden="true">
|
|
969
|
+
<path d="M5 5L15 15M15 5L5 15" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
970
|
+
</svg>
|
|
971
|
+
</button>
|
|
972
|
+
|
|
973
|
+
<aside
|
|
974
|
+
class="absolute inset-y-0 left-0 w-[min(22rem,calc(100vw-2.5rem))] max-w-full overflow-y-auto overscroll-contain border-r border-slate-200/80 bg-white shadow-[0_28px_90px_rgba(15,23,42,0.22)] transition-transform duration-300"
|
|
975
|
+
:class="isOpen ? 'translate-x-0' : 'pointer-events-none -translate-x-[105%]'"
|
|
976
|
+
>
|
|
977
|
+
<DocsMobileMenu
|
|
978
|
+
:logo-src="logoSrc"
|
|
979
|
+
:site-title="siteTitle"
|
|
980
|
+
@navigate="close"
|
|
981
|
+
/>
|
|
982
|
+
</aside>
|
|
983
|
+
</div>
|
|
937
984
|
|
|
938
985
|
<div
|
|
939
|
-
class="mx-auto grid h-[calc(100dvh-
|
|
986
|
+
class="mx-auto grid h-[calc(100dvh-7rem)] min-h-0 w-full max-w-[96rem] rounded-2xl px-2 lg:h-[calc(100dvh-4rem)] lg:grid-cols-[16.5rem_minmax(0,1fr)] lg:gap-x-2 lg:px-4"
|
|
940
987
|
:class="hasSidebar ? '' : 'lg:grid-cols-[minmax(0,1fr)]'"
|
|
941
988
|
>
|
|
942
989
|
<div
|
|
@@ -979,7 +1026,7 @@ onBeforeUnmount(() => {
|
|
|
979
1026
|
<div
|
|
980
1027
|
id="docs-scroll-container"
|
|
981
1028
|
ref="docsScrollContainer"
|
|
982
|
-
class="stable-scrollbar-gutter h-full overflow-y-auto rounded-xl border border-gray-400/30 bg-white px-
|
|
1029
|
+
class="stable-scrollbar-gutter h-full overflow-y-auto rounded-xl border border-gray-400/30 bg-white px-4 pb-10 pt-6 lg:px-10 lg:pt-10"
|
|
983
1030
|
>
|
|
984
1031
|
<div
|
|
985
1032
|
class="mx-auto w-full max-w-[88rem] xl:grid xl:grid-cols-[minmax(0,52rem)_16.5rem] xl:justify-center xl:gap-x-12"
|
package/src/custom.css
CHANGED
|
@@ -100,6 +100,21 @@
|
|
|
100
100
|
z-index: 1;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/*
|
|
104
|
+
* The heading anchor hangs into the left gutter, but the scroll container clips
|
|
105
|
+
* both axes (overflow-y: auto forces overflow-x to auto — it can't be
|
|
106
|
+
* `visible`), so below lg — where the card padding is only px-3 — the anchor
|
|
107
|
+
* gets cut off and there's no clean way to reveal it without stealing content
|
|
108
|
+
* width. It's a hover affordance anyway (touch devices never show it), so just
|
|
109
|
+
* hide it below lg; the copy-on-tap heading behaviour still works. On lg+ the
|
|
110
|
+
* card's px-10 padding gives it room, so it stays.
|
|
111
|
+
*/
|
|
112
|
+
@media (max-width: 1023.98px) {
|
|
113
|
+
.vp-doc :where(h2, h3, h4, h5, h6).docs-copyable-heading>.anchor-heading__icon-wrap {
|
|
114
|
+
display: none;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
103
118
|
.vp-doc :where(h2, h3, h4, h5, h6).docs-copyable-heading>.anchor-heading__icon-wrap>.header-anchor {
|
|
104
119
|
display: inline-flex;
|
|
105
120
|
align-items: center;
|