@commonpub/layer 0.4.9 → 0.4.11

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.
@@ -10,14 +10,14 @@ const props = defineProps<{
10
10
  federatedId?: string;
11
11
  }>();
12
12
 
13
- // Detect V2 ExplainerDocument format vs legacy BlockTuple[] format
14
- const isV2Format = computed(() => isExplainerDocument(props.content?.content));
15
- const v2Document = computed<ExplainerDocument | null>(() =>
16
- isV2Format.value ? (props.content.content as unknown as ExplainerDocument) : null,
13
+ // Check if content is the new ExplainerDocument format
14
+ const isDocumentFormat = computed(() => isExplainerDocument(props.content?.content));
15
+ const explainerDoc = computed<ExplainerDocument | null>(() =>
16
+ isDocumentFormat.value ? (props.content.content as unknown as ExplainerDocument) : null,
17
17
  );
18
18
 
19
19
  const blocks = computed<BlockTuple[]>(() => {
20
- if (isV2Format.value) return []; // V2 uses its own viewer
20
+ if (isDocumentFormat.value) return [];
21
21
  const raw = props.content?.content;
22
22
  if (!Array.isArray(raw)) return [];
23
23
  return raw as BlockTuple[];
@@ -164,10 +164,10 @@ onUnmounted(() => { document.removeEventListener('keydown', onKeydown); });
164
164
  </script>
165
165
 
166
166
  <template>
167
- <!-- V2 Scroll Viewer for ExplainerDocument format -->
168
- <ScrollViewer v-if="isV2Format && v2Document" :document="v2Document" />
167
+ <!-- Scroll viewer for ExplainerDocument format -->
168
+ <ScrollViewer v-if="isDocumentFormat && explainerDoc" :document="explainerDoc" />
169
169
 
170
- <!-- Legacy slide-deck viewer for BlockTuple[] format -->
170
+ <!-- Block-based viewer fallback -->
171
171
  <div v-else class="cpub-explainer-view">
172
172
  <!-- PROGRESS BAR -->
173
173
  <div class="cpub-progress-line">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonpub/layer",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "files": [
@@ -50,16 +50,16 @@
50
50
  "vue": "^3.4.0",
51
51
  "vue-router": "^4.3.0",
52
52
  "zod": "^4.3.6",
53
- "@commonpub/editor": "0.5.0",
54
- "@commonpub/schema": "0.8.13",
55
- "@commonpub/explainer": "0.5.3",
56
53
  "@commonpub/auth": "0.5.0",
54
+ "@commonpub/editor": "0.5.0",
57
55
  "@commonpub/learning": "0.5.0",
58
- "@commonpub/docs": "0.5.2",
56
+ "@commonpub/schema": "0.8.14",
59
57
  "@commonpub/config": "0.8.0",
58
+ "@commonpub/explainer": "0.5.3",
59
+ "@commonpub/docs": "0.5.2",
60
60
  "@commonpub/ui": "0.8.4",
61
- "@commonpub/protocol": "0.9.5",
62
- "@commonpub/server": "2.22.1"
61
+ "@commonpub/server": "2.23.0",
62
+ "@commonpub/protocol": "0.9.5"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@testing-library/jest-dom": "^6.9.1",
@@ -9,9 +9,9 @@ const pagePath = computed(() => {
9
9
  return Array.isArray(p) ? p[p.length - 1] : p;
10
10
  });
11
11
 
12
- const { data: site } = useLazyFetch(() => `/api/docs/${siteSlug.value}`);
13
- const { data: nav } = useLazyFetch(() => `/api/docs/${siteSlug.value}/nav`);
14
- const { data: pages } = useLazyFetch(() => `/api/docs/${siteSlug.value}/pages`);
12
+ const { data: site } = useLazyFetch<{ id: string; name: string; slug: string; description: string; ownerId: string; versions: Array<{ id: string; label: string; slug: string; version: string; isDefault: boolean }> }>(() => `/api/docs/${siteSlug.value}`);
13
+ const { data: nav } = useLazyFetch<Array<{ id: string; title: string; slug: string; sortOrder: number; parentId: string | null }>>(() => `/api/docs/${siteSlug.value}/nav`);
14
+ const { data: pages } = useLazyFetch<Array<{ id: string; title: string; slug: string; sortOrder: number; parentId: string | null }>>(() => `/api/docs/${siteSlug.value}/pages`);
15
15
 
16
16
  // Fetch the rendered page (server-side markdown rendering or block content)
17
17
  interface RenderedPage {
@@ -10,8 +10,8 @@ const siteSlug = computed(() => route.params.siteSlug as string);
10
10
  const { show: toast } = useToast();
11
11
 
12
12
  // ═══ DATA FETCHING ═══
13
- const { data: site, refresh: refreshSite } = await useFetch(() => `/api/docs/${siteSlug.value}`);
14
- const { data: rawPages, refresh: refreshPages } = await useFetch(() => `/api/docs/${siteSlug.value}/pages`);
13
+ const { data: site, refresh: refreshSite } = await useFetch<{ id: string; name: string; slug: string; description: string; ownerId: string }>(() => `/api/docs/${siteSlug.value}`);
14
+ const { data: rawPages, refresh: refreshPages } = await useFetch<Array<{ id: string; title: string; slug: string; sortOrder: number; parentId: string | null; content: string | BlockTuple[] | null; format?: string }>>(() => `/api/docs/${siteSlug.value}/pages`);
15
15
 
16
16
  useSeoMeta({ title: () => `Edit ${site.value?.name ?? 'Docs'} — ${useSiteName()}` });
17
17
 
@@ -512,7 +512,7 @@ async function createVersion(): Promise<void> {
512
512
  <div class="cpub-docs-field">
513
513
  <label class="cpub-docs-field-label">Parent</label>
514
514
  <div class="cpub-docs-field-value">
515
- {{ selectedPage.parentId ? pages.find(p => p.id === selectedPage.parentId)?.title ?? 'Unknown' : 'Top level' }}
515
+ {{ selectedPage?.parentId ? pages.find(p => p.id === selectedPage!.parentId)?.title ?? 'Unknown' : 'Top level' }}
516
516
  </div>
517
517
  <span class="cpub-docs-field-hint">Drag pages in the tree to change hierarchy</span>
518
518
  </div>
@@ -2,9 +2,9 @@
2
2
  const route = useRoute();
3
3
  const siteSlug = computed(() => route.params.siteSlug as string);
4
4
 
5
- const { data: site, pending: sitePending, error: siteError, refresh: refreshSite } = useLazyFetch(() => `/api/docs/${siteSlug.value}`);
6
- const { data: nav } = useLazyFetch(() => `/api/docs/${siteSlug.value}/nav`);
7
- const { data: pages } = useLazyFetch(() => `/api/docs/${siteSlug.value}/pages`);
5
+ const { data: site, pending: sitePending, error: siteError, refresh: refreshSite } = useLazyFetch<{ id: string; name: string; slug: string; description: string; ownerId: string; versions: Array<{ id: string; label: string; slug: string; version: string; isDefault: boolean }> }>(() => `/api/docs/${siteSlug.value}`);
6
+ const { data: nav } = useLazyFetch<Array<{ id: string; title: string; slug: string; sortOrder: number; parentId: string | null }>>(() => `/api/docs/${siteSlug.value}/nav`);
7
+ const { data: pages } = useLazyFetch<Array<{ id: string; title: string; slug: string; sortOrder: number; parentId: string | null }>>(() => `/api/docs/${siteSlug.value}/pages`);
8
8
 
9
9
  const { user } = useAuth();
10
10
  const isOwner = computed(() => site.value && user.value && site.value.ownerId === user.value.id);
@@ -170,9 +170,9 @@ async function handleSave(): Promise<void> {
170
170
  method: 'PUT',
171
171
  body: {
172
172
  ...form.value,
173
- skills: skills.value.filter((s) => s.name.trim()),
174
- socialLinks: socialLinks.value,
173
+ skills: skills.value.filter((s) => s.name.trim()).map((s) => s.name),
175
174
  experience: experience.value.filter((e) => e.title.trim()),
175
+ socialLinks: socialLinks.value,
176
176
  ...(emailNotificationsEnabled.value ? { emailNotifications: emailNotifications.value } : {}),
177
177
  },
178
178
  });