@notionx/create-notionx-app 2.0.0 → 2.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/dist/templates/lib/blog/translations.ts.tmpl +1 -1
- package/dist/templates/lib/locale-contract/index.ts.tmpl +1 -1
- package/dist/templates/lib/pages/source.ts.tmpl +4 -1
- package/dist/templates/lib/search/config.ts.tmpl +17 -4
- package/dist/templates/lib/site/request-env.ts.tmpl +5 -3
- package/dist/templates/lib/site/settings.ts.tmpl +3 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { i18n } from "@/lib/i18n";
|
|
12
12
|
import { blogContract } from "@/lib/locale-contract";
|
|
13
13
|
import { blogTranslationsSource } from "@/lib/content/models";
|
|
14
|
-
import type { NotionPageLike } from "@notionx/core";
|
|
14
|
+
import type { NotionPageLike } from "@notionx/core/notion";
|
|
15
15
|
|
|
16
16
|
export type BlogTranslationExtra = {
|
|
17
17
|
summary: string;
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
createSitePagesApi,
|
|
11
11
|
type SitePage as BaseSitePage,
|
|
12
|
-
type SitePageBlockRef,
|
|
13
12
|
} from "@notionx/core/pages";
|
|
14
13
|
import { blocksSource, contentSources } from "@/lib/content/models";
|
|
15
14
|
import { getRequestLocale } from "@/lib/site/request-env";
|
|
@@ -53,6 +52,10 @@ export type SitePage = Omit<BaseSitePage, "structuredBlocks"> & {
|
|
|
53
52
|
structuredBlocks: StructuredPageBlock[];
|
|
54
53
|
};
|
|
55
54
|
|
|
55
|
+
// `SitePageBlockRef` is not exported from `@notionx/core/pages`,
|
|
56
|
+
// but it is the element type of `SitePage.structuredBlocks`.
|
|
57
|
+
type SitePageBlockRef = BaseSitePage["structuredBlocks"][number];
|
|
58
|
+
|
|
56
59
|
const fallbackStructuredBlocks: Record<string, StructuredPageBlock> = {
|
|
57
60
|
"home-hero": {
|
|
58
61
|
slug: "home-hero",
|
|
@@ -9,15 +9,28 @@
|
|
|
9
9
|
|
|
10
10
|
import { createD1SearchAdapter } from "@notionx/core/search";
|
|
11
11
|
import type { SearchAdapter } from "@notionx/core/search";
|
|
12
|
+
import type { SqlDatabaseAdapter } from "@notionx/core/platform";
|
|
12
13
|
import { getRequestEnv } from "../site/request-env";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
* Lazily resolve the D1 database binding from the request environment
|
|
16
|
-
*
|
|
16
|
+
* Lazily resolve the D1 database binding from the request environment
|
|
17
|
+
* and wrap it in the `SqlDatabaseAdapter` shape expected by
|
|
18
|
+
* `@notionx/core/search`. The adapter is created once and reused
|
|
19
|
+
* across requests.
|
|
17
20
|
*/
|
|
18
|
-
function getDatabase() {
|
|
21
|
+
function getDatabase(): SqlDatabaseAdapter {
|
|
19
22
|
const env = getRequestEnv();
|
|
20
|
-
|
|
23
|
+
if (!env?.DB) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"D1 database binding DB is not available in the request environment."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
kind: "d1",
|
|
30
|
+
prepare: (query) => env.DB!.prepare(query),
|
|
31
|
+
batch: (statements) =>
|
|
32
|
+
env.DB!.batch(statements as D1PreparedStatement[]),
|
|
33
|
+
};
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
export const searchAdapter: SearchAdapter = createD1SearchAdapter(getDatabase);
|
|
@@ -40,12 +40,14 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Shape of the Cloudflare `env` parameter as far as this project
|
|
43
|
-
* is concerned.
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* is concerned. Bindings read outside the worker entry (e.g. D1
|
|
44
|
+
* from the search adapter, KV from site settings) are propagated
|
|
45
|
+
* through ALS; others are accessed by the foundation worker
|
|
46
|
+
* directly and don't need to be listed here.
|
|
46
47
|
*/
|
|
47
48
|
export interface RequestEnv {
|
|
48
49
|
CONTENT_CACHE?: KVNamespace;
|
|
50
|
+
DB?: D1Database;
|
|
49
51
|
/**
|
|
50
52
|
* Locale resolved by the middleware from the `/{locale}` path
|
|
51
53
|
* prefix. Server components and data loaders read this via
|
|
@@ -50,9 +50,12 @@ function readKv(): KVNamespace | null {
|
|
|
50
50
|
return getRequestEnv()?.CONTENT_CACHE ?? null;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Mirrors `SiteConfig["navigation"]["main"]`: the JSON stored in
|
|
54
|
+
// Notion's "Nav" field should include `modelId` for each item.
|
|
53
55
|
type RawNavItem = {
|
|
54
56
|
label: string;
|
|
55
57
|
href: string;
|
|
58
|
+
modelId: string;
|
|
56
59
|
children?: RawNavItem[];
|
|
57
60
|
};
|
|
58
61
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notionx/create-notionx-app",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Scaffold a new vinext (Next.js on Cloudflare Workers + D1 + R2) project backed by @notionx/core, with one-step provisioning of D1 / KV / R2 / Turnstile / Notion / Resend / Google OAuth.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|