@abraca/junis 2.86.0 → 2.88.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/dist/module.d.mts +4 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +82 -8
- package/dist/runtime/assets/css/jun.css +2 -2
- package/dist/runtime/components/JunDocSurface.d.vue.ts +20 -2
- package/dist/runtime/components/JunDocSurface.vue +30 -2
- package/dist/runtime/components/JunDocSurface.vue.d.ts +20 -2
- package/dist/runtime/components/JunHead.vue +16 -4
- package/dist/runtime/components/JunNavDock.d.vue.ts +15 -0
- package/dist/runtime/components/JunNavDock.vue +94 -0
- package/dist/runtime/components/JunNavDock.vue.d.ts +15 -0
- package/dist/runtime/components/JunNavMenu.client.d.vue.ts +15 -0
- package/dist/runtime/components/JunNavMenu.client.vue +478 -0
- package/dist/runtime/components/JunNavMenu.client.vue.d.ts +15 -0
- package/dist/runtime/components/JunNavPreview.d.vue.ts +17 -0
- package/dist/runtime/components/JunNavPreview.vue +169 -0
- package/dist/runtime/components/JunNavPreview.vue.d.ts +17 -0
- package/dist/runtime/components/JunNavigation.d.vue.ts +4 -11
- package/dist/runtime/components/JunNavigation.vue +813 -138
- package/dist/runtime/components/JunNavigation.vue.d.ts +4 -11
- package/dist/runtime/components/JunNoteLinks.vue +1 -1
- package/dist/runtime/components/JunPageHero.vue +3 -3
- package/dist/runtime/components/JunSectionBar.d.vue.ts +41 -0
- package/dist/runtime/components/JunSectionBar.vue +144 -0
- package/dist/runtime/components/JunSectionBar.vue.d.ts +41 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +486 -6
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +48 -0
- package/dist/runtime/components/renderers/JunGlobeRenderer.vue +43 -26
- package/dist/runtime/composables/useJunCreatePage.js +7 -1
- package/dist/runtime/composables/useJunDocPage.d.ts +28 -0
- package/dist/runtime/composables/useJunDocPage.js +111 -20
- package/dist/runtime/composables/useJunGarden.d.ts +1 -1
- package/dist/runtime/composables/useJunGarden.js +3 -2
- package/dist/runtime/composables/useJunGestures.d.ts +53 -0
- package/dist/runtime/composables/useJunGestures.js +89 -0
- package/dist/runtime/composables/useJunMenuState.d.ts +4 -0
- package/dist/runtime/composables/useJunMenuState.js +5 -0
- package/dist/runtime/composables/useJunNavItems.d.ts +50 -0
- package/dist/runtime/composables/useJunNavItems.js +188 -0
- package/dist/runtime/composables/useJunNavSettings.d.ts +58 -1
- package/dist/runtime/composables/useJunNavSettings.js +110 -8
- package/dist/runtime/composables/useJunOptions.d.ts +1 -0
- package/dist/runtime/composables/useJunSiblings.d.ts +30 -0
- package/dist/runtime/composables/useJunSiblings.js +38 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +51 -3
- package/dist/runtime/composables/useJunTheme.js +4 -1
- package/dist/runtime/composables/useJunViewingAccent.js +10 -0
- package/dist/runtime/layouts/jun.vue +21 -1
- package/dist/runtime/pages/doc.vue +41 -35
- package/dist/runtime/pages/index.vue +63 -35
- package/dist/runtime/plugins/jun-doc-tree.d.ts +2 -0
- package/dist/runtime/plugins/jun-doc-tree.js +26 -0
- package/dist/runtime/server/api/health.get.d.ts +15 -0
- package/dist/runtime/server/api/health.get.js +7 -2
- package/dist/runtime/server/api/links.get.js +27 -3
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +20 -0
- package/dist/runtime/server/api/resolve/[...slug].get.js +33 -2
- package/dist/runtime/server/api/search.get.d.ts +1 -1
- package/dist/runtime/server/api/search.get.js +42 -39
- package/dist/runtime/server/api/tree.get.d.ts +9 -0
- package/dist/runtime/server/api/tree.get.js +25 -0
- package/dist/runtime/server/janitor/junJanitorActor.d.ts +13 -0
- package/dist/runtime/server/janitor/junJanitorActor.js +36 -5
- package/dist/runtime/server/janitor/junJanitorChores.d.ts +14 -7
- package/dist/runtime/server/janitor/junJanitorChores.js +21 -3
- package/dist/runtime/server/janitor/junJanitorMachine.js +36 -4
- package/dist/runtime/server/janitor/junJanitorPerform.d.ts +15 -1
- package/dist/runtime/server/janitor/junJanitorPerform.js +13 -5
- package/dist/runtime/server/janitor/junJanitorYText.d.ts +40 -3
- package/dist/runtime/server/janitor/junJanitorYText.js +60 -14
- package/dist/runtime/server/plugins/jun-janitor.js +132 -81
- package/dist/runtime/server/routes/jun-card.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-card.png.get.js +40 -0
- package/dist/runtime/server/utils/junCard.d.ts +39 -0
- package/dist/runtime/server/utils/junCard.js +159 -0
- package/dist/runtime/server/utils/junIcon.d.ts +27 -2
- package/dist/runtime/server/utils/junIcon.js +5 -5
- package/dist/runtime/server/utils/junJanitorStatus.d.ts +59 -0
- package/dist/runtime/server/utils/junJanitorStatus.js +27 -0
- package/dist/runtime/types.d.ts +225 -0
- package/dist/runtime/utils/junAdopt.d.ts +43 -0
- package/dist/runtime/utils/junAdopt.js +7 -0
- package/dist/runtime/utils/junGesture.d.ts +84 -0
- package/dist/runtime/utils/junGesture.js +40 -0
- package/dist/runtime/utils/junLetters.d.ts +86 -0
- package/dist/runtime/utils/junLetters.js +173 -0
- package/dist/runtime/utils/junNavValue.d.ts +56 -0
- package/dist/runtime/utils/junNavValue.js +36 -0
- package/dist/runtime/utils/junSearchRank.d.ts +79 -0
- package/dist/runtime/utils/junSearchRank.js +73 -0
- package/dist/runtime/utils/junSocial.d.ts +59 -0
- package/dist/runtime/utils/junSocial.js +56 -0
- package/dist/runtime/utils/junViewSpecs.d.ts +38 -0
- package/dist/runtime/utils/junViewSpecs.js +92 -1
- package/package.json +10 -8
- /package/dist/runtime/components/{JunSectionPresence.client.d.vue.ts → JunSectionPresence.d.vue.ts} +0 -0
- /package/dist/runtime/components/{JunSectionPresence.client.vue → JunSectionPresence.vue} +0 -0
- /package/dist/runtime/components/{JunSectionPresence.client.vue.d.ts → JunSectionPresence.vue.d.ts} +0 -0
|
@@ -59,33 +59,50 @@ function onMapAdd(at) {
|
|
|
59
59
|
class="bg-black"
|
|
60
60
|
:class="isEmbedded ? 'absolute inset-0 [contain:layout_paint]' : 'fixed inset-0'"
|
|
61
61
|
>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
:waypoints="waypoints"
|
|
65
|
-
:selected-id="selectedId"
|
|
66
|
-
:adding="adding"
|
|
67
|
-
:awareness="awareness"
|
|
68
|
-
@ready="mapReady = true"
|
|
69
|
-
@select="onSelect"
|
|
70
|
-
@mapadd="onMapAdd"
|
|
71
|
-
/>
|
|
62
|
+
<!-- The one renderer that is deliberately CLIENT-ONLY, and the exception
|
|
63
|
+
proves the rule the rest of the module now follows.
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
Everything else server-renders: the tree is in the payload, so a poll
|
|
66
|
+
ships its tally and a library its shelves. A globe ships a WebGL canvas,
|
|
67
|
+
which cannot exist on a server at all — and the timeline floating over it
|
|
68
|
+
is positioned against that canvas and gated on the map's `ready` event.
|
|
69
|
+
Server-rendering the overlay alone produced exactly what you would
|
|
70
|
+
expect: `ready` false on the server and true after mount, so Vue
|
|
71
|
+
reported "server rendered element contains fewer child nodes than client
|
|
72
|
+
vdom" on every waypoint, plus `class="null"` on each icon. There is no
|
|
73
|
+
SEO or cold-read value being traded away — the page's content is a map.
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
The document's PROSE and meta still server-render through the resolve
|
|
76
|
+
payload and `<JunHead>`; only the canvas and its overlay wait. -->
|
|
77
|
+
<ClientOnly>
|
|
78
|
+
<JunGlobeMap
|
|
79
|
+
ref="mapRef"
|
|
80
|
+
:waypoints="waypoints"
|
|
81
|
+
:selected-id="selectedId"
|
|
82
|
+
:adding="adding"
|
|
83
|
+
:awareness="awareness"
|
|
84
|
+
@ready="mapReady = true"
|
|
85
|
+
@select="onSelect"
|
|
86
|
+
@mapadd="onMapAdd"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<JunHorizontalTimeline
|
|
90
|
+
:waypoints="waypoints"
|
|
91
|
+
:selected-id="selectedId"
|
|
92
|
+
:ready="mapReady"
|
|
93
|
+
@select="onSelect"
|
|
94
|
+
@focus-route="onFocusRoute"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<JunGlobeEditor
|
|
98
|
+
v-if="editing"
|
|
99
|
+
ref="editorRef"
|
|
100
|
+
v-model:adding="adding"
|
|
101
|
+
:tree="tree"
|
|
102
|
+
:waypoints="waypoints"
|
|
103
|
+
:map="mapRef"
|
|
104
|
+
@select="onSelect"
|
|
105
|
+
/>
|
|
106
|
+
</ClientOnly>
|
|
90
107
|
</div>
|
|
91
108
|
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useAbracadabra, useChildTree, useDocSlugs, useRouter } from "#imports";
|
|
2
|
+
import { junAdoptedMeta } from "../utils/junAdopt.js";
|
|
2
3
|
export function useJunCreatePage() {
|
|
3
4
|
const abra = useAbracadabra();
|
|
4
5
|
const tree = useChildTree(abra.doc, "jun-create-page");
|
|
@@ -17,7 +18,12 @@ export function useJunCreatePage() {
|
|
|
17
18
|
order: now,
|
|
18
19
|
type,
|
|
19
20
|
createdAt: now,
|
|
20
|
-
updatedAt: now
|
|
21
|
+
updatedAt: now,
|
|
22
|
+
// Only somebody with write access can reach this function, so this page
|
|
23
|
+
// is the SITE rather than litter — see `junAdopt`. Without it a janitor
|
|
24
|
+
// running in `clean` mode removes a page made in the studio within a
|
|
25
|
+
// patrol or two, which is correct for a demo and wrong for a site.
|
|
26
|
+
meta: junAdoptedMeta()
|
|
21
27
|
});
|
|
22
28
|
tree.registerDoc(id, parent, { label, type });
|
|
23
29
|
if (options.navigate !== false) {
|
|
@@ -57,6 +57,34 @@ export interface JunResolvedDoc {
|
|
|
57
57
|
parentId?: string | null;
|
|
58
58
|
parentType?: string | null;
|
|
59
59
|
parentTitle?: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Every ancestor, root-first — `[{ id, title, slug }]`.
|
|
62
|
+
*
|
|
63
|
+
* A breadcrumb the client can walk from the live tree, but a crawler reads
|
|
64
|
+
* the page before there IS a live tree, which is why the trail is sent.
|
|
65
|
+
*/
|
|
66
|
+
trail?: {
|
|
67
|
+
id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
slug: string | null;
|
|
70
|
+
}[];
|
|
71
|
+
/**
|
|
72
|
+
* The pages beside this one — the children of its top-level ancestor.
|
|
73
|
+
*
|
|
74
|
+
* What `<JunSectionBar>` draws before the live tree can answer. `null` on the
|
|
75
|
+
* home page, whose children ARE the navbar.
|
|
76
|
+
*/
|
|
77
|
+
section?: {
|
|
78
|
+
parentId: string;
|
|
79
|
+
parentTitle: string;
|
|
80
|
+
parentSlug: string | null;
|
|
81
|
+
items: {
|
|
82
|
+
id: string;
|
|
83
|
+
title: string;
|
|
84
|
+
slug: string | null;
|
|
85
|
+
icon?: string;
|
|
86
|
+
}[];
|
|
87
|
+
} | null;
|
|
60
88
|
html?: string | null;
|
|
61
89
|
}
|
|
62
90
|
export type JunLayoutBucket = 'immersive' | 'panel' | 'flowing';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, onUnmounted, watchEffect } from "vue";
|
|
2
|
-
import { useHead, useNuxtData, useSeoMeta } from "#app";
|
|
2
|
+
import { useHead, useNuxtData, useRequestURL, useSeoMeta } from "#app";
|
|
3
|
+
import { useRoute } from "vue-router";
|
|
3
4
|
import {
|
|
4
5
|
useDocTree,
|
|
5
6
|
useJunBrand,
|
|
@@ -10,8 +11,17 @@ import {
|
|
|
10
11
|
junConfigStr,
|
|
11
12
|
isJunOwnerOnlyDoc
|
|
12
13
|
} from "#imports";
|
|
13
|
-
import { JUN_CHROME_OPTIONS } from "../utils/junViewSpecs.js";
|
|
14
|
+
import { JUN_CHROME_OPTIONS, JUN_HERO_OPTIONS } from "../utils/junViewSpecs.js";
|
|
14
15
|
import { junResolveViewValue } from "../utils/junViewValues.js";
|
|
16
|
+
import {
|
|
17
|
+
junAbsoluteUrl,
|
|
18
|
+
junIsArticleOg,
|
|
19
|
+
junIsoTime,
|
|
20
|
+
junOgType,
|
|
21
|
+
junOrigin
|
|
22
|
+
} from "../utils/junSocial.js";
|
|
23
|
+
import { junFingerprint } from "../utils/junIdentity.js";
|
|
24
|
+
import { junCanDraw } from "../utils/junLetters.js";
|
|
15
25
|
const FLAG = {
|
|
16
26
|
chromeNav: "no-nav",
|
|
17
27
|
chromeFooter: "no-footer",
|
|
@@ -97,16 +107,11 @@ export function useJunDocPage(docId, options = {}) {
|
|
|
97
107
|
meta: resolved?.value?.meta
|
|
98
108
|
})
|
|
99
109
|
);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// an untitled page; returning it here too would run it through the
|
|
104
|
-
// template and render `Jun!s — Jun!s`.
|
|
105
|
-
title: computed(() => {
|
|
106
|
-
if (!canEdit.value && ownerOnly.value) return void 0;
|
|
107
|
-
return entry.value?.label ?? resolved?.value?.title ?? void 0;
|
|
108
|
-
})
|
|
110
|
+
const pageTitle = computed(() => {
|
|
111
|
+
if (!canEdit.value && ownerOnly.value) return void 0;
|
|
112
|
+
return entry.value?.label ?? resolved?.value?.title ?? void 0;
|
|
109
113
|
});
|
|
114
|
+
useHead({ title: pageTitle });
|
|
110
115
|
const description = computed(() => {
|
|
111
116
|
if (!(!canEdit.value && ownerOnly.value)) {
|
|
112
117
|
const meta = entry.value?.meta ?? resolved?.value?.meta ?? {};
|
|
@@ -115,21 +120,71 @@ export function useJunDocPage(docId, options = {}) {
|
|
|
115
120
|
}
|
|
116
121
|
return junConfigStr(siteConfig.value.seoDescription) ?? brand.value.seoDescription;
|
|
117
122
|
});
|
|
118
|
-
const
|
|
123
|
+
const jsonLdObject = computed(() => {
|
|
119
124
|
const type = docType.value;
|
|
120
125
|
const builder = isItem.value ? itemPresentation.value?.jsonLd : type ? opts.jsonLd?.[type] : void 0;
|
|
121
|
-
if (!builder || !resolved?.value?.found || ownerOnly.value) return
|
|
122
|
-
|
|
126
|
+
if (!builder || !resolved?.value?.found || ownerOnly.value) return null;
|
|
127
|
+
return junBuildJsonLd(builder, {
|
|
123
128
|
title: resolved.value.title ?? "",
|
|
124
129
|
meta: resolved.value.meta ?? {},
|
|
125
130
|
authorName: junConfigStr(siteConfig.value.authorName) ?? brand.value.name,
|
|
126
131
|
description: description.value
|
|
127
132
|
});
|
|
128
|
-
|
|
133
|
+
});
|
|
134
|
+
const jsonLd = computed(() => jsonLdObject.value ? JSON.stringify(jsonLdObject.value) : "");
|
|
135
|
+
const requestUrl = useRequestURL();
|
|
136
|
+
const route = useRoute();
|
|
137
|
+
const origin = computed(() => junOrigin(
|
|
138
|
+
junConfigStr(siteConfig.value.seoSiteUrl),
|
|
139
|
+
requestUrl.origin
|
|
140
|
+
));
|
|
141
|
+
const canonicalPath = computed(() => {
|
|
142
|
+
const former = resolved?.value?.canonical;
|
|
143
|
+
return former ? `/${former}` : route.path;
|
|
144
|
+
});
|
|
145
|
+
const canonicalUrl = computed(() => junAbsoluteUrl(origin.value, canonicalPath.value));
|
|
146
|
+
const ogType = computed(() => junOgType(jsonLdObject.value?.["@type"]));
|
|
147
|
+
const publishedTime = computed(
|
|
148
|
+
() => junIsArticleOg(ogType.value) ? junIsoTime(jsonLdObject.value?.datePublished) : void 0
|
|
149
|
+
);
|
|
150
|
+
const modifiedTime = computed(() => {
|
|
151
|
+
if (!junIsArticleOg(ogType.value)) return void 0;
|
|
152
|
+
const meta = entry.value?.meta ?? resolved?.value?.meta ?? {};
|
|
153
|
+
return junIsoTime(entry.value?.updatedAt ?? meta.updatedAt) ?? publishedTime.value;
|
|
154
|
+
});
|
|
155
|
+
const socialImage = computed(() => {
|
|
156
|
+
const meta = entry.value?.meta ?? resolved?.value?.meta ?? {};
|
|
157
|
+
const own = junConfigStr(meta.socialImage);
|
|
158
|
+
if (own) return /^https?:\/\//i.test(own) ? own : junAbsoluteUrl(origin.value, own);
|
|
159
|
+
const configured = junConfigStr(siteConfig.value.seoOgImage);
|
|
160
|
+
if (configured) return /^https?:\/\//i.test(configured) ? configured : junAbsoluteUrl(origin.value, configured);
|
|
161
|
+
if (!opts.features.socialCards) return void 0;
|
|
162
|
+
const id = docId.value;
|
|
163
|
+
if (!id) return void 0;
|
|
164
|
+
if (!junCanDraw(pageTitle.value ?? "")) return void 0;
|
|
165
|
+
const key = junFingerprint([pageTitle.value, docType.value, description.value].join("|"));
|
|
166
|
+
return junAbsoluteUrl(origin.value, `/jun-card.png?d=${encodeURIComponent(id)}&k=${key}`);
|
|
129
167
|
});
|
|
130
168
|
useSeoMeta({
|
|
131
169
|
description: () => description.value,
|
|
132
|
-
ogDescription: () => description.value
|
|
170
|
+
ogDescription: () => description.value,
|
|
171
|
+
ogTitle: () => pageTitle.value,
|
|
172
|
+
twitterTitle: () => pageTitle.value,
|
|
173
|
+
twitterDescription: () => description.value,
|
|
174
|
+
ogUrl: () => canonicalUrl.value,
|
|
175
|
+
ogType: () => ogType.value,
|
|
176
|
+
ogImage: () => socialImage.value,
|
|
177
|
+
twitterImage: () => socialImage.value,
|
|
178
|
+
articlePublishedTime: () => publishedTime.value,
|
|
179
|
+
articleModifiedTime: () => modifiedTime.value
|
|
180
|
+
});
|
|
181
|
+
useHead({
|
|
182
|
+
link: computed(() => (
|
|
183
|
+
// Only when the origin is known. A RELATIVE canonical is legal and
|
|
184
|
+
// useless; an absolute one built on a guessed origin points a crawler
|
|
185
|
+
// somewhere else entirely.
|
|
186
|
+
origin.value ? [{ key: "jun-canonical", rel: "canonical", href: canonicalUrl.value }] : []
|
|
187
|
+
))
|
|
133
188
|
});
|
|
134
189
|
const typeKey = computed(() => {
|
|
135
190
|
const id = docType.value;
|
|
@@ -154,16 +209,52 @@ export function useJunDocPage(docId, options = {}) {
|
|
|
154
209
|
const flags = off.filter(Boolean).join(" ");
|
|
155
210
|
return flags || void 0;
|
|
156
211
|
});
|
|
212
|
+
const heroStyle = computed(() => {
|
|
213
|
+
const meta = entry.value?.meta ?? resolved?.value?.meta ?? {};
|
|
214
|
+
const stored = meta.junView && typeof meta.junView === "object" && !Array.isArray(meta.junView) ? meta.junView : {};
|
|
215
|
+
const key = typeKey.value;
|
|
216
|
+
const house = key ? {
|
|
217
|
+
...opts.renderers?.[key] ?? {},
|
|
218
|
+
...siteConfig.value.renderers?.[key] ?? {}
|
|
219
|
+
} : {};
|
|
220
|
+
const option = JUN_HERO_OPTIONS[0];
|
|
221
|
+
const value = junResolveViewValue(option, stored, house, meta);
|
|
222
|
+
return typeof value === "string" && value !== "classic" ? value : void 0;
|
|
223
|
+
});
|
|
157
224
|
useHead({
|
|
158
225
|
htmlAttrs: {
|
|
159
226
|
"data-jun-type": computed(() => typeKey.value),
|
|
160
|
-
"data-jun-chrome": computed(() => chromeFlags.value)
|
|
227
|
+
"data-jun-chrome": computed(() => chromeFlags.value),
|
|
228
|
+
"data-jun-hero": computed(() => heroStyle.value)
|
|
161
229
|
}
|
|
162
230
|
});
|
|
231
|
+
const breadcrumbLd = computed(() => {
|
|
232
|
+
const trail = resolved?.value?.trail ?? [];
|
|
233
|
+
if (!origin.value || ownerOnly.value || !pageTitle.value) return "";
|
|
234
|
+
const items = [
|
|
235
|
+
...trail.map((step) => ({
|
|
236
|
+
name: step.title,
|
|
237
|
+
url: junAbsoluteUrl(origin.value, step.slug ? `/${step.slug}` : "/")
|
|
238
|
+
})),
|
|
239
|
+
{ name: pageTitle.value, url: canonicalUrl.value }
|
|
240
|
+
].filter((step) => !!step.name);
|
|
241
|
+
if (items.length < 2) return "";
|
|
242
|
+
return JSON.stringify({
|
|
243
|
+
"@context": "https://schema.org",
|
|
244
|
+
"@type": "BreadcrumbList",
|
|
245
|
+
"itemListElement": items.map((step, i) => ({
|
|
246
|
+
"@type": "ListItem",
|
|
247
|
+
"position": i + 1,
|
|
248
|
+
"name": step.name,
|
|
249
|
+
"item": step.url
|
|
250
|
+
}))
|
|
251
|
+
});
|
|
252
|
+
});
|
|
163
253
|
useHead({
|
|
164
|
-
script: computed(
|
|
165
|
-
|
|
166
|
-
|
|
254
|
+
script: computed(() => [
|
|
255
|
+
...jsonLd.value ? [{ key: "jun-jsonld", type: "application/ld+json", textContent: jsonLd.value }] : [],
|
|
256
|
+
...breadcrumbLd.value ? [{ key: "jun-breadcrumb-ld", type: "application/ld+json", textContent: breadcrumbLd.value }] : []
|
|
257
|
+
])
|
|
167
258
|
});
|
|
168
259
|
return {
|
|
169
260
|
entry,
|
|
@@ -39,7 +39,7 @@ export interface JunLinkGraph {
|
|
|
39
39
|
* falls through to the SPA catch-all and resolves with the page's HTML. That is not
|
|
40
40
|
* a thrown error, so a `try`/`catch` never sees it; only checking the shape does.
|
|
41
41
|
*/
|
|
42
|
-
export declare function useJunLinkGraph(): {
|
|
42
|
+
export declare function useJunLinkGraph(docId?: string): {
|
|
43
43
|
graph: ComputedRef<JunLinkGraph>;
|
|
44
44
|
refresh: () => Promise<void>;
|
|
45
45
|
};
|
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
} from "../utils/junGarden.js";
|
|
10
10
|
import { isJunOwnerOnlyDoc } from "../utils/junVisibility.js";
|
|
11
11
|
const EMPTY = { nodes: [], edges: [], scanned: 0, generatedAt: 0 };
|
|
12
|
-
export function useJunLinkGraph() {
|
|
12
|
+
export function useJunLinkGraph(docId) {
|
|
13
13
|
const opts = useJunOptions();
|
|
14
14
|
const { data, refresh } = useFetch(`${opts.apiBase}/links`, {
|
|
15
|
-
key: "jun-links",
|
|
15
|
+
key: docId ? `jun-links-${docId}` : "jun-links",
|
|
16
|
+
query: docId ? { doc: docId } : void 0,
|
|
16
17
|
default: () => EMPTY
|
|
17
18
|
});
|
|
18
19
|
const graph = computed(() => {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useJunGestures — swipe to turn the page, swipe from the edge to open the menu.
|
|
3
|
+
*
|
|
4
|
+
* The detection is `@abraca/nuxt`'s (`useSwipeGesture`, `useEdgeSwipe`), shared
|
|
5
|
+
* with cou-sh. Everything here is what a swipe MEANS on a site made of
|
|
6
|
+
* documents: which page is next, when the gesture applies, and how much of it
|
|
7
|
+
* to draw.
|
|
8
|
+
*
|
|
9
|
+
* ## Where it is mounted, and why only there
|
|
10
|
+
*
|
|
11
|
+
* The FLOWING bucket only — an ordinary reading page. The immersive and panel
|
|
12
|
+
* buckets are renderers that own their own pointer (a globe drags, a deck
|
|
13
|
+
* pages, a mosaic pans), and a page-level swipe would be competing with the
|
|
14
|
+
* thing the reader is actually touching. Those types can adopt the same
|
|
15
|
+
* composable themselves, deliberately, one at a time.
|
|
16
|
+
*
|
|
17
|
+
* ## What suppresses it
|
|
18
|
+
*
|
|
19
|
+
* Editing, an open overlay, a site that switched it off, and anything inside
|
|
20
|
+
* `data-swipe-ignore` — the navbar's own horizontal track, the editor, the
|
|
21
|
+
* timeline. That last one is the composable's own rule and costs nothing here.
|
|
22
|
+
*
|
|
23
|
+
* ## What it does NOT do
|
|
24
|
+
*
|
|
25
|
+
* Take over the browser's back gesture. Edge swipe OPENS things; history stays
|
|
26
|
+
* the platform's. `preventBrowserGesture` is left off for exactly that reason:
|
|
27
|
+
* on a site, the reader's swipe-to-go-back is worth more than a second way to
|
|
28
|
+
* reach the menu.
|
|
29
|
+
*/
|
|
30
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
31
|
+
export interface JunGestureOptions {
|
|
32
|
+
/** The layout bucket this page is in. Only `flowing` gets page swipes. */
|
|
33
|
+
bucket: () => string;
|
|
34
|
+
/** The document being read. */
|
|
35
|
+
docId: Ref<string | null> | ComputedRef<string | null>;
|
|
36
|
+
/** The config snapshot, already fetched by the page. */
|
|
37
|
+
config: ComputedRef<Record<string, unknown>>;
|
|
38
|
+
}
|
|
39
|
+
export declare function useJunGestures(el: Ref<HTMLElement | null>, options: JunGestureOptions): {
|
|
40
|
+
swipeOffset: Ref<{
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
}, {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
} | {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
}>;
|
|
50
|
+
isSwiping: Ref<boolean, boolean>;
|
|
51
|
+
neighbours: ComputedRef<import("#imports").JunNeighbourPair<import("#imports").JunSibling>>;
|
|
52
|
+
applies: ComputedRef<boolean>;
|
|
53
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { computed, ref } from "vue";
|
|
2
|
+
import { useRouter } from "vue-router";
|
|
3
|
+
import { useDocSlugs, useEdgeSwipe, useSwipeGesture } from "#imports";
|
|
4
|
+
import { useJunImagePopup } from "./useJunImagePopup.js";
|
|
5
|
+
import { useJunMenuState } from "./useJunMenuState.js";
|
|
6
|
+
import { useJunNavSettings } from "./useJunNavSettings.js";
|
|
7
|
+
import { useJunOptions } from "./useJunOptions.js";
|
|
8
|
+
import { useJunSiblings } from "./useJunSiblings.js";
|
|
9
|
+
import { junConfigOn } from "./useJunSiteConfigValues.js";
|
|
10
|
+
import { useJunStudio } from "./useJunStudio.js";
|
|
11
|
+
import { junSwipeApplies, junSwipeDamp, junSwipeNeighbour } from "../utils/junGesture.js";
|
|
12
|
+
export function useJunGestures(el, options) {
|
|
13
|
+
const opts = useJunOptions();
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
const { getDocUrl } = useDocSlugs();
|
|
16
|
+
const { editing } = useJunStudio();
|
|
17
|
+
const { state: popup } = useJunImagePopup();
|
|
18
|
+
const { open: menuOpen } = useJunMenuState();
|
|
19
|
+
const nav = useJunNavSettings();
|
|
20
|
+
const { neighbours } = useJunSiblings(options.docId);
|
|
21
|
+
const reducedMotion = ref(false);
|
|
22
|
+
if (import.meta.client) {
|
|
23
|
+
reducedMotion.value = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
|
|
24
|
+
}
|
|
25
|
+
const pageSwipeOn = computed(() => opts.features.gestures && junConfigOn(options.config.value.gesturePages ?? true));
|
|
26
|
+
const edgeSwipeOn = computed(() => opts.features.gestures && junConfigOn(options.config.value.gestureEdge ?? true));
|
|
27
|
+
const overlayOpen = computed(() => menuOpen.value || !!popup.value);
|
|
28
|
+
if (!opts.features.gestures) {
|
|
29
|
+
return {
|
|
30
|
+
swipeOffset: ref({ x: 0, y: 0 }),
|
|
31
|
+
isSwiping: ref(false),
|
|
32
|
+
neighbours,
|
|
33
|
+
applies: computed(() => false)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const applies = computed(() => junSwipeApplies({
|
|
37
|
+
enabled: pageSwipeOn.value,
|
|
38
|
+
bucket: options.bucket(),
|
|
39
|
+
editing: editing.value,
|
|
40
|
+
overlayOpen: overlayOpen.value
|
|
41
|
+
}));
|
|
42
|
+
function go(direction) {
|
|
43
|
+
const target = junSwipeNeighbour(direction, neighbours.value);
|
|
44
|
+
if (!target) return;
|
|
45
|
+
const url = getDocUrl(target.id);
|
|
46
|
+
if (url) void router.push(url);
|
|
47
|
+
}
|
|
48
|
+
const { swipeOffset, isSwiping } = useSwipeGesture({
|
|
49
|
+
el,
|
|
50
|
+
axis: "x",
|
|
51
|
+
/*
|
|
52
|
+
* TOUCH ONLY, and this was measured rather than assumed.
|
|
53
|
+
*
|
|
54
|
+
* `useSwipeGesture` also counts wheel deltas, which is right for a pager —
|
|
55
|
+
* cou-sh flicks through slides and windows that way. On a reading page it
|
|
56
|
+
* is a trap: a Mac trackpad emits horizontal deltas whenever somebody
|
|
57
|
+
* brushes sideways past a wide code block, and eight of them navigated a
|
|
58
|
+
* documentation page to its neighbour under a reader who had not asked to
|
|
59
|
+
* go anywhere.
|
|
60
|
+
*/
|
|
61
|
+
pointer: "touch",
|
|
62
|
+
disabled: () => !applies.value,
|
|
63
|
+
damp: () => junSwipeDamp(reducedMotion.value),
|
|
64
|
+
// `canSwipe*` is about DAMPING, not permission: a direction with nothing
|
|
65
|
+
// in it still moves, a quarter as far, so the end of a collection is felt
|
|
66
|
+
// rather than merely not happening.
|
|
67
|
+
canSwipeLeft: () => !!neighbours.value.next,
|
|
68
|
+
canSwipeRight: () => !!neighbours.value.prev,
|
|
69
|
+
onSwipeLeft: () => go("left"),
|
|
70
|
+
onSwipeRight: () => go("right")
|
|
71
|
+
});
|
|
72
|
+
useEdgeSwipe({
|
|
73
|
+
disabled: () => !edgeSwipeOn.value || !nav.menuEnabled.value || editing.value || overlayOpen.value,
|
|
74
|
+
onFromLeft: () => {
|
|
75
|
+
menuOpen.value = true;
|
|
76
|
+
},
|
|
77
|
+
onFromRight: () => {
|
|
78
|
+
menuOpen.value = true;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
/** Live offset while a finger is down — bind it as a transform. */
|
|
83
|
+
swipeOffset,
|
|
84
|
+
isSwiping,
|
|
85
|
+
neighbours,
|
|
86
|
+
/** Whether a page swipe would do anything right now. */
|
|
87
|
+
applies
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useJunNavItems — everything a NAVIGATION ITEM knows about itself.
|
|
3
|
+
*
|
|
4
|
+
* The navbar used to be the only thing that rendered one, so all of this lived
|
|
5
|
+
* inside `JunNavigation`. There are three surfaces now — the track, the mobile
|
|
6
|
+
* menu and the dock — and every one of them needs the same six answers about
|
|
7
|
+
* the same item: what it is called, what icon it wears, where it actually
|
|
8
|
+
* goes, what is underneath it, who is standing on it, and whether it changed
|
|
9
|
+
* since this visitor last looked.
|
|
10
|
+
*
|
|
11
|
+
* The PRESENTATIONS are deliberately not shared: a pill, a menu row and a dock
|
|
12
|
+
* tab are different shapes, and a component flexible enough to be all three
|
|
13
|
+
* would be worse than three templates. The DATA is shared, because two copies
|
|
14
|
+
* of "does presence bubble up from the subtree" is how two surfaces come to
|
|
15
|
+
* disagree about how many people are on a page.
|
|
16
|
+
*/
|
|
17
|
+
import { type Ref } from 'vue';
|
|
18
|
+
import { type JunTraveller } from './useJunPresence.js';
|
|
19
|
+
export interface JunNavigationItem {
|
|
20
|
+
id?: string;
|
|
21
|
+
name: string;
|
|
22
|
+
href: string;
|
|
23
|
+
type?: string;
|
|
24
|
+
icon?: string;
|
|
25
|
+
current: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** A child page of a nav item, for the submenus and the menu's accordion. */
|
|
28
|
+
export interface JunNavChild {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
href: string;
|
|
32
|
+
icon?: string;
|
|
33
|
+
type?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function useJunNavItems(items: Ref<JunNavigationItem[]>, options?: {
|
|
36
|
+
trackSeen?: boolean;
|
|
37
|
+
}): {
|
|
38
|
+
activeTrail: () => string[];
|
|
39
|
+
labelOf: (id: string) => string;
|
|
40
|
+
iconFor: (item: JunNavigationItem) => string;
|
|
41
|
+
navLabelFor: (item: JunNavigationItem) => string;
|
|
42
|
+
redirectTargetFor: (item: JunNavigationItem) => string | null;
|
|
43
|
+
isExternalTarget: (u: string | null) => boolean;
|
|
44
|
+
childrenOf: (id?: string) => JunNavChild[];
|
|
45
|
+
freshFor: (item: JunNavigationItem) => boolean;
|
|
46
|
+
countFor: (item: JunNavigationItem) => number | null;
|
|
47
|
+
presenceFor: (id?: string) => JunTraveller[];
|
|
48
|
+
topAncestorOf: (id: string) => string | null;
|
|
49
|
+
subtreeMaxById: import("vue").ComputedRef<Map<string, number>>;
|
|
50
|
+
};
|