@backmatter/next 0.0.37 → 0.0.39
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 +3 -3
- package/src/brand-icon.ts +8 -0
- package/src/routes.ts +12 -1
- package/src/studio.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backmatter/next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "Experimental Next.js adapter for Backmatter. APIs will break. Not ready for production.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"test": "bun test"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@backmatter/core": "^0.0.
|
|
50
|
+
"@backmatter/core": "^0.0.33",
|
|
51
51
|
"@mdx-js/mdx": "^3.1.1",
|
|
52
52
|
"remark-gfm": "^4.0.1",
|
|
53
|
-
"@backmatter/studio": "^0.0.
|
|
53
|
+
"@backmatter/studio": "^0.0.16"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"next": ">=16.3.0",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// packages/next/src/brand-icon.ts
|
|
2
|
+
// Same knockout circle as public/icon-black.png, drawn so the Studio
|
|
3
|
+
// document can carry a favicon without a file on the customer host.
|
|
4
|
+
// The asterisk is a hole; tab chrome shows through it.
|
|
5
|
+
|
|
6
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 406 406"><style>.disc{fill:#18181b}@media (prefers-color-scheme: dark){.disc{fill:#fafafa}}</style><defs><mask id="m"><rect width="406" height="406" fill="#fff"/><g fill="#000"><rect x="63.5" y="189.5" width="279" height="27" rx="13.5"/><rect x="63.5" y="189.5" width="279" height="27" rx="13.5" transform="rotate(45 203 203)"/><rect x="63.5" y="189.5" width="279" height="27" rx="13.5" transform="rotate(90 203 203)"/><rect x="63.5" y="189.5" width="279" height="27" rx="13.5" transform="rotate(135 203 203)"/></g></mask></defs><circle class="disc" cx="203" cy="203" r="203" mask="url(#m)"/></svg>`;
|
|
7
|
+
|
|
8
|
+
export const brandIconHref = `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
package/src/routes.ts
CHANGED
|
@@ -385,7 +385,7 @@ export function createCatchAll<Models extends readonly ModelDef[]>(
|
|
|
385
385
|
if (!hit) return failFor();
|
|
386
386
|
const body = await publishedBody(hit.type, hit.slug);
|
|
387
387
|
if (body == null) return body;
|
|
388
|
-
return createElement(Fragment, null, docBridge(hit), body);
|
|
388
|
+
return createElement(Fragment, null, docMarker(hit), docBridge(hit), body);
|
|
389
389
|
};
|
|
390
390
|
|
|
391
391
|
const PreviewBranch = async ({
|
|
@@ -411,12 +411,23 @@ export function createCatchAll<Models extends readonly ModelDef[]>(
|
|
|
411
411
|
__html: "[data-backmatter-published]{display:none!important}",
|
|
412
412
|
},
|
|
413
413
|
}),
|
|
414
|
+
docMarker(hit),
|
|
414
415
|
docBridge(hit),
|
|
415
416
|
await loadPreviewDoc(hit, preview),
|
|
416
417
|
),
|
|
417
418
|
);
|
|
418
419
|
};
|
|
419
420
|
|
|
421
|
+
function docMarker(hit: RouteHit) {
|
|
422
|
+
if (cms.config.workspaceId) return null;
|
|
423
|
+
return createElement("span", {
|
|
424
|
+
hidden: true,
|
|
425
|
+
"data-backmatter-doc": "",
|
|
426
|
+
"data-type": hit.type,
|
|
427
|
+
"data-slug": hit.slug,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
420
431
|
function docBridge(hit: RouteHit) {
|
|
421
432
|
if (!cms.config.workspaceId) return null;
|
|
422
433
|
return createElement(SiteDocBridge, {
|
package/src/studio.tsx
CHANGED
|
@@ -23,6 +23,7 @@ import type { BackmatterClient } from "@backmatter/core/node/create-backmatter";
|
|
|
23
23
|
import studioPkg from "@backmatter/studio/package.json";
|
|
24
24
|
import type { StudioDefinition } from "@backmatter/studio/define";
|
|
25
25
|
import { requestUrlFrom } from "./request-url";
|
|
26
|
+
import { brandIconHref } from "./brand-icon";
|
|
26
27
|
import { StudioMount, StudioSignedOut } from "./studio-client";
|
|
27
28
|
|
|
28
29
|
export { requestUrlFrom };
|
|
@@ -143,6 +144,7 @@ export function StudioLayout({ children }: { children: ReactNode }) {
|
|
|
143
144
|
<html lang="en" suppressHydrationWarning>
|
|
144
145
|
<head>
|
|
145
146
|
<meta name="robots" content="noindex, nofollow" />
|
|
147
|
+
<link rel="icon" href={brandIconHref} type="image/svg+xml" />
|
|
146
148
|
<script dangerouslySetInnerHTML={{ __html: THEME_BOOT }} />
|
|
147
149
|
</head>
|
|
148
150
|
<body style={{ margin: 0 }}>
|