create-smoodly-app 0.0.35 → 0.0.36

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.
Files changed (58) hide show
  1. package/package.json +1 -1
  2. package/templates/blank/app/(site)/layout.tsx +2 -2
  3. package/templates/blank/components/pages/Home.tsx +1 -1
  4. package/templates/blank/components/pages/Page.tsx +1 -1
  5. package/templates/blank/components/pages/Post.tsx +5 -7
  6. package/templates/blank/package.json +1 -1
  7. package/templates/blank/smoodly/admin.tsx +2 -2
  8. package/templates/blank/smoodly/server.ts +3 -3
  9. package/templates/blank/supabase/migrations/20260930040956_smoodly_v7.sql +84 -0
  10. package/templates/blank/supabase/migrations/{20260929135623_smoodly_views.sql → 20260930041056_smoodly_views.sql} +3 -6
  11. package/templates/blank-intl/app/[locale]/layout.tsx +2 -2
  12. package/templates/blank-intl/components/pages/Home.tsx +1 -1
  13. package/templates/blank-intl/components/pages/Page.tsx +1 -1
  14. package/templates/blank-intl/components/pages/Post.tsx +5 -7
  15. package/templates/blank-intl/package.json +1 -1
  16. package/templates/blank-intl/smoodly/admin.tsx +2 -2
  17. package/templates/blank-intl/smoodly/server.ts +3 -3
  18. package/templates/blank-intl/supabase/migrations/20260930040956_smoodly_v7.sql +84 -0
  19. package/templates/blank-intl/supabase/migrations/{20260929135623_smoodly_views.sql → 20260930041056_smoodly_views.sql} +3 -6
  20. package/templates/lorem/app/(site)/layout.tsx +2 -2
  21. package/templates/lorem/components/PageFrame.tsx +1 -1
  22. package/templates/lorem/components/articles.ts +0 -1
  23. package/templates/lorem/components/news.ts +0 -1
  24. package/templates/lorem/components/pages/Article.tsx +32 -14
  25. package/templates/lorem/components/pages/Articles.tsx +4 -6
  26. package/templates/lorem/components/pages/Home.tsx +1 -1
  27. package/templates/lorem/components/pages/News.tsx +8 -12
  28. package/templates/lorem/components/pages/NewsPost.tsx +6 -6
  29. package/templates/lorem/components/pages/Page.tsx +1 -1
  30. package/templates/lorem/components/sections/FavouriteArticles.tsx +2 -3
  31. package/templates/lorem/components/sections/People.tsx +1 -1
  32. package/templates/lorem/messages/en.json +1 -0
  33. package/templates/lorem/package.json +1 -1
  34. package/templates/lorem/smoodly/admin.tsx +2 -2
  35. package/templates/lorem/smoodly/collections.ts +2 -0
  36. package/templates/lorem/smoodly/server.ts +3 -3
  37. package/templates/lorem/supabase/migrations/20260930040956_smoodly_v7.sql +84 -0
  38. package/templates/lorem/supabase/migrations/{20260929135623_smoodly_views.sql → 20260930041056_smoodly_views.sql} +4 -10
  39. package/templates/lorem-intl/app/[locale]/layout.tsx +2 -2
  40. package/templates/lorem-intl/components/PageFrame.tsx +1 -1
  41. package/templates/lorem-intl/components/articles.ts +0 -1
  42. package/templates/lorem-intl/components/news.ts +0 -1
  43. package/templates/lorem-intl/components/pages/Article.tsx +32 -14
  44. package/templates/lorem-intl/components/pages/Articles.tsx +4 -6
  45. package/templates/lorem-intl/components/pages/Home.tsx +1 -1
  46. package/templates/lorem-intl/components/pages/News.tsx +8 -12
  47. package/templates/lorem-intl/components/pages/NewsPost.tsx +6 -6
  48. package/templates/lorem-intl/components/pages/Page.tsx +1 -1
  49. package/templates/lorem-intl/components/sections/FavouriteArticles.tsx +2 -3
  50. package/templates/lorem-intl/components/sections/People.tsx +1 -1
  51. package/templates/lorem-intl/messages/en.json +1 -0
  52. package/templates/lorem-intl/messages/fi.json +1 -0
  53. package/templates/lorem-intl/package.json +1 -1
  54. package/templates/lorem-intl/smoodly/admin.tsx +2 -2
  55. package/templates/lorem-intl/smoodly/collections.ts +2 -0
  56. package/templates/lorem-intl/smoodly/server.ts +3 -3
  57. package/templates/lorem-intl/supabase/migrations/20260930040956_smoodly_v7.sql +84 -0
  58. package/templates/lorem-intl/supabase/migrations/{20260929135623_smoodly_views.sql → 20260930041056_smoodly_views.sql} +4 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-smoodly-app",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "description": "Create a Smoodly site: a fresh Next.js app with the admin mounted, a Supabase schema, an env file and a first editor.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,7 +11,7 @@ import "../globals.css";
11
11
  // absolute; SITE_URL is the deployed address (spec 2026-09-29 pre-install fixes §6).
12
12
  export async function generateMetadata() {
13
13
  const site = await q().getGlobal("site");
14
- return { metadataBase: new URL(process.env.SITE_URL || "http://localhost:3000"), title: site?.name ?? "Smoodly site" };
14
+ return { metadataBase: new URL(process.env.SITE_URL || "http://localhost:3000"), title: site?.fields.name ?? "Smoodly site" };
15
15
  }
16
16
 
17
17
  export default async function RootLayout({ children }: { children: ReactNode }) {
@@ -20,7 +20,7 @@ export default async function RootLayout({ children }: { children: ReactNode })
20
20
  <html lang="en">
21
21
  <body>
22
22
  <main>{children}</main>
23
- {site && <footer className="container site-footer">{site.name} · {site.tagline}</footer>}
23
+ {site && <footer className="container site-footer">{site.fields.name} · {site.fields.tagline}</footer>}
24
24
  </body>
25
25
  </html>
26
26
  );
@@ -13,7 +13,7 @@ export const homeSchema = smoodly.schema.page({
13
13
  zones: {
14
14
  body: z.freeform({ sections: [Text], custom: true }),
15
15
  },
16
- meta: { seo: true },
16
+ seo: true,
17
17
  });
18
18
 
19
19
  function HomeView({ zones, page }: Props<typeof homeSchema>) {
@@ -11,7 +11,7 @@ export const pageSchema = smoodly.schema.page({
11
11
  zones: {
12
12
  body: z.freeform({ sections: [Text], custom: true }),
13
13
  },
14
- meta: { seo: true },
14
+ seo: true,
15
15
  });
16
16
 
17
17
  function PageView({ zones, page }: Props<typeof pageSchema>) {
@@ -1,4 +1,4 @@
1
- import { smoodly, type EntryPageProps } from "smoodly";
1
+ import { smoodly } from "smoodly";
2
2
  import { RichText } from "@/smoodly/richtext";
3
3
  import { posts } from "@/smoodly/collections";
4
4
  import { LocaleNav } from "../LocaleNav";
@@ -6,10 +6,9 @@ import { LocaleNav } from "../LocaleNav";
6
6
  // The entry page for `posts`, served at /posts/<slug>. It receives the
7
7
  // entry's fields; the body is richtext rendered by the site's bound
8
8
  // RichText, which knows the registered elements.
9
- type PostFields = { title: string; date?: string; body?: unknown };
10
-
11
- function PostView({ entry, locale, locales }: EntryPageProps) {
12
- const post = entry.fields as PostFields;
9
+ export const PostPage = smoodly.entryPage(posts, function PostView({ entry }) {
10
+ const { locale, locales } = entry;
11
+ const post = entry.fields;
13
12
  return (
14
13
  <>
15
14
  <LocaleNav locale={locale} locales={locales} />
@@ -20,6 +19,5 @@ function PostView({ entry, locale, locales }: EntryPageProps) {
20
19
  </article>
21
20
  </>
22
21
  );
23
- }
22
+ });
24
23
 
25
- export const PostPage = smoodly.entryPage(posts, PostView);
@@ -14,7 +14,7 @@
14
14
  "next": "^16.3.4",
15
15
  "react": "^19",
16
16
  "react-dom": "^19",
17
- "smoodly": "0.0.35"
17
+ "smoodly": "0.0.36"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@next/env": "^16.3.4",
@@ -1,6 +1,6 @@
1
1
  import { createSmoodlyAdmin } from "smoodly/admin/next";
2
2
  import { config } from "./config";
3
3
  import { smoodlyOp } from "./ops";
4
- import { publicAuth, publicContent } from "./server";
4
+ import { publicAuth, presence } from "./server";
5
5
 
6
- export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, content: publicContent });
6
+ export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, presence });
@@ -9,7 +9,7 @@
9
9
  // admin route enters it from config.ts — so nothing here may read the
10
10
  // config at module scope.
11
11
  import {
12
- createSmoodlyClient, createSmoodlySite, publicContentConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type ContentConfig, type SmoodlySite,
12
+ createSmoodlyClient, createSmoodlySite, presenceConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type PresenceConfig, type SmoodlySite,
13
13
  } from "smoodly";
14
14
  // The admin gate from `smoodly/admin`, which holds no client code: the site
15
15
  // routes import this file, and `smoodly/admin/next` would put the admin
@@ -89,8 +89,8 @@ export function publicAuth(): AuthConfig {
89
89
 
90
90
  /** What the browser needs to join the editing-presence channel — public values only (spec 2026-09-26 concurrency §5).
91
91
  * The space is asked of the database once per process. */
92
- export function publicContent(): Promise<ContentConfig> {
93
- return publicContentConfig(smoodlyEnv());
92
+ export function presence(): Promise<PresenceConfig> {
93
+ return presenceConfig(smoodlyEnv());
94
94
  }
95
95
 
96
96
  /** Locale-relative CMS path → site URL: the one seam for the renderer
@@ -0,0 +1,84 @@
1
+ -- Smoodly core schema, version 7 (docs/superpowers/specs/2026-09-29-content-api-contract-design.md §5).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 6: smoodly_list_entries, which filters, orders and
5
+ -- limits a collection over the snapshot the reader is shown, and the read
6
+ -- policies of every content table admit a write key only (§8).
7
+
8
+ -- The shown snapshot of one collection's entries in a locale, filtered,
9
+ -- ordered and limited in one query (spec 2026-09-29 content API contract
10
+ -- §5): the published snapshot, or the live merge in preview. Invoker
11
+ -- rights, so RLS decides what a key sees; a preview read needs the
12
+ -- service role or a write key, anything else reads published.
13
+ create or replace function "smoodly_list_entries"(
14
+ p_collection text, p_locale text, p_draft boolean, p_where jsonb, p_order jsonb,
15
+ p_limit integer, p_parent uuid, p_has_parent boolean, p_ids uuid[]
16
+ ) returns table ("id" uuid, "fields" jsonb) language sql stable set search_path = public as $$
17
+ with mode as (
18
+ select p_draft and (current_user = 'service_role' or "smoodly_key_kind"() = 'write') as draft
19
+ ), shown as (
20
+ select e."id", e."sort", e."created_at", l."updated_at",
21
+ case when (select draft from mode) then e."fields" || l."fields" || jsonb_build_object('slug', l."slug")
22
+ else coalesce(v."fields", e."fields" || l."fields" || jsonb_build_object('slug', l."slug")) end as "fields"
23
+ from "entries" e
24
+ join "entry_locales" l on l."entry_id" = e."id" and l."locale" = p_locale
25
+ left join "entry_versions" v on v."id" = l."published_version_id"
26
+ where e."collection" = p_collection
27
+ and ((select draft from mode) or l."status" = 'published')
28
+ and (not p_has_parent or e."parent_id" is not distinct from p_parent)
29
+ and (p_ids is null or e."id" = any(p_ids))
30
+ )
31
+ select s."id", s."fields" from shown s
32
+ where not exists (
33
+ select 1 from jsonb_each(coalesce(p_where, '{}'::jsonb)) w
34
+ where not (case when w.value ? 'in'
35
+ then (s."fields" ->> w.key) = any (select jsonb_array_elements_text(w.value -> 'in'))
36
+ else s."fields" @> jsonb_build_object(w.key, w.value -> 'contains') end))
37
+ order by
38
+ case when p_order ->> 'by' = 'manual' then s."sort" end asc nulls last,
39
+ case when p_order ->> 'direction' = 'asc' then
40
+ case p_order ->> 'by' when 'createdAt' then to_jsonb(s."created_at") when 'updatedAt' then to_jsonb(s."updated_at")
41
+ when 'manual' then null else nullif(nullif(s."fields" -> (p_order ->> 'by'), 'null'::jsonb), '""'::jsonb) end end asc nulls last,
42
+ case when p_order ->> 'direction' = 'desc' then
43
+ case p_order ->> 'by' when 'createdAt' then to_jsonb(s."created_at") when 'updatedAt' then to_jsonb(s."updated_at")
44
+ when 'manual' then null else nullif(nullif(s."fields" -> (p_order ->> 'by'), 'null'::jsonb), '""'::jsonb) end end desc nulls last,
45
+ s."created_at" asc, s."id" asc
46
+ limit p_limit;
47
+ $$;
48
+
49
+ -- No public content reads (spec 2026-09-29 content API contract §8): the
50
+ -- publishable key and a read key read nothing; a write key reads its own space.
51
+ drop policy if exists "smoodly_read" on "pages";
52
+ create policy "smoodly_read" on "pages" for select
53
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
54
+
55
+ drop policy if exists "smoodly_read" on "page_locales";
56
+ create policy "smoodly_read" on "page_locales" for select
57
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
58
+
59
+ drop policy if exists "smoodly_read" on "page_versions";
60
+ create policy "smoodly_read" on "page_versions" for select
61
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
62
+
63
+ drop policy if exists "smoodly_read" on "entries";
64
+ create policy "smoodly_read" on "entries" for select
65
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
66
+
67
+ drop policy if exists "smoodly_read" on "entry_locales";
68
+ create policy "smoodly_read" on "entry_locales" for select
69
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
70
+
71
+ drop policy if exists "smoodly_read" on "entry_versions";
72
+ create policy "smoodly_read" on "entry_versions" for select
73
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
74
+
75
+ drop policy if exists "smoodly_read" on "paths";
76
+ create policy "smoodly_read" on "paths" for select
77
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
78
+
79
+ drop policy if exists "smoodly_read" on "assets";
80
+ create policy "smoodly_read" on "assets" for select
81
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
82
+
83
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '7')
84
+ on conflict ("key") do update set "value" = excluded."value";
@@ -1,8 +1,8 @@
1
- -- Smoodly: read views and order indexes for this app's collections, written by `npx smoodly migrate`
2
- -- (2026-09-29T13:56:23.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
1
+ -- Smoodly: read views for this app's collections, written by `npx smoodly migrate`
2
+ -- (2026-09-30T04:10:56.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
3
3
  -- Never edit a written file: change the collection and run migrate again.
4
4
 
5
- -- smoodly:collection posts sha256:2e648b887b8e7146
5
+ -- smoodly:collection posts sha256:38ba2918f83ab367
6
6
  create or replace view "posts" with (security_invoker = true) as
7
7
  select
8
8
  e."id",
@@ -18,6 +18,3 @@ from "entries" e
18
18
  join "entry_locales" l on l."entry_id" = e."id"
19
19
  left join "entry_versions" v on v."id" = l."published_version_id"
20
20
  where e."collection" = 'posts' and l."status" = 'published';
21
-
22
- create index if not exists "entries_posts_date_idx"
23
- on "entries" (("fields"->'date')) where "collection" = 'posts';
@@ -19,7 +19,7 @@ import "../globals.css";
19
19
  export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
20
20
  const { locale } = await params;
21
21
  const site = await q().getGlobal("site", { locale });
22
- return { metadataBase: new URL(process.env.SITE_URL || "http://localhost:3000"), title: site?.name ?? "Smoodly site" };
22
+ return { metadataBase: new URL(process.env.SITE_URL || "http://localhost:3000"), title: site?.fields.name ?? "Smoodly site" };
23
23
  }
24
24
 
25
25
  export default async function LocaleLayout({ children, params }: { children: ReactNode; params: Promise<{ locale: string }> }) {
@@ -31,7 +31,7 @@ export default async function LocaleLayout({ children, params }: { children: Rea
31
31
  <body>
32
32
  <NextIntlClientProvider>
33
33
  <main>{children}</main>
34
- {site && <footer className="container site-footer">{site.name} · {site.tagline}</footer>}
34
+ {site && <footer className="container site-footer">{site.fields.name} · {site.fields.tagline}</footer>}
35
35
  </NextIntlClientProvider>
36
36
  </body>
37
37
  </html>
@@ -13,7 +13,7 @@ export const homeSchema = smoodly.schema.page({
13
13
  zones: {
14
14
  body: z.freeform({ sections: [Text], custom: true }),
15
15
  },
16
- meta: { seo: true },
16
+ seo: true,
17
17
  });
18
18
 
19
19
  function HomeView({ zones, page }: Props<typeof homeSchema>) {
@@ -11,7 +11,7 @@ export const pageSchema = smoodly.schema.page({
11
11
  zones: {
12
12
  body: z.freeform({ sections: [Text], custom: true }),
13
13
  },
14
- meta: { seo: true },
14
+ seo: true,
15
15
  });
16
16
 
17
17
  function PageView({ zones, page }: Props<typeof pageSchema>) {
@@ -1,4 +1,4 @@
1
- import { smoodly, type EntryPageProps } from "smoodly";
1
+ import { smoodly } from "smoodly";
2
2
  import { RichText } from "@/smoodly/richtext";
3
3
  import { posts } from "@/smoodly/collections";
4
4
  import { LocaleNav } from "../LocaleNav";
@@ -6,10 +6,9 @@ import { LocaleNav } from "../LocaleNav";
6
6
  // The entry page for `posts`, served at /posts/<slug>. It receives the
7
7
  // entry's fields; the body is richtext rendered by the site's bound
8
8
  // RichText, which knows the registered elements.
9
- type PostFields = { title: string; date?: string; body?: unknown };
10
-
11
- function PostView({ entry, locale, locales }: EntryPageProps) {
12
- const post = entry.fields as PostFields;
9
+ export const PostPage = smoodly.entryPage(posts, function PostView({ entry }) {
10
+ const { locale, locales } = entry;
11
+ const post = entry.fields;
13
12
  return (
14
13
  <>
15
14
  <LocaleNav locale={locale} locales={locales} />
@@ -20,6 +19,5 @@ function PostView({ entry, locale, locales }: EntryPageProps) {
20
19
  </article>
21
20
  </>
22
21
  );
23
- }
22
+ });
24
23
 
25
- export const PostPage = smoodly.entryPage(posts, PostView);
@@ -14,7 +14,7 @@
14
14
  "next": "^16.3.4",
15
15
  "react": "^19",
16
16
  "react-dom": "^19",
17
- "smoodly": "0.0.35",
17
+ "smoodly": "0.0.36",
18
18
  "next-intl": "^4.14.2"
19
19
  },
20
20
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  import { createSmoodlyAdmin } from "smoodly/admin/next";
2
2
  import { config } from "./config";
3
3
  import { smoodlyOp } from "./ops";
4
- import { publicAuth, publicContent } from "./server";
4
+ import { publicAuth, presence } from "./server";
5
5
 
6
- export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, content: publicContent });
6
+ export const { AdminPage, AdminLayout } = createSmoodlyAdmin({ config, op: smoodlyOp, auth: publicAuth, presence });
@@ -9,7 +9,7 @@
9
9
  // admin route enters it from config.ts — so nothing here may read the
10
10
  // config at module scope.
11
11
  import {
12
- createSmoodlyClient, createSmoodlySite, publicContentConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type ContentConfig, type SmoodlySite,
12
+ createSmoodlyClient, createSmoodlySite, presenceConfig, smoodlyEnv, SupabaseAssetStore, SupabaseEntryStore, SupabaseMemberStore, SupabasePageStore, SupabasePathIndex, type PresenceConfig, type SmoodlySite,
13
13
  } from "smoodly";
14
14
  // The admin gate from `smoodly/admin`, which holds no client code: the site
15
15
  // routes import this file, and `smoodly/admin/next` would put the admin
@@ -90,8 +90,8 @@ export function publicAuth(): AuthConfig {
90
90
 
91
91
  /** What the browser needs to join the editing-presence channel — public values only (spec 2026-09-26 concurrency §5).
92
92
  * The space is asked of the database once per process. */
93
- export function publicContent(): Promise<ContentConfig> {
94
- return publicContentConfig(smoodlyEnv());
93
+ export function presence(): Promise<PresenceConfig> {
94
+ return presenceConfig(smoodlyEnv());
95
95
  }
96
96
 
97
97
  /** Locale-relative CMS path → site URL: the one seam for the renderer
@@ -0,0 +1,84 @@
1
+ -- Smoodly core schema, version 7 (docs/superpowers/specs/2026-09-29-content-api-contract-design.md §5).
2
+ -- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
3
+ -- Never edit a published file: the next change is the next file.
4
+ -- The delta over version 6: smoodly_list_entries, which filters, orders and
5
+ -- limits a collection over the snapshot the reader is shown, and the read
6
+ -- policies of every content table admit a write key only (§8).
7
+
8
+ -- The shown snapshot of one collection's entries in a locale, filtered,
9
+ -- ordered and limited in one query (spec 2026-09-29 content API contract
10
+ -- §5): the published snapshot, or the live merge in preview. Invoker
11
+ -- rights, so RLS decides what a key sees; a preview read needs the
12
+ -- service role or a write key, anything else reads published.
13
+ create or replace function "smoodly_list_entries"(
14
+ p_collection text, p_locale text, p_draft boolean, p_where jsonb, p_order jsonb,
15
+ p_limit integer, p_parent uuid, p_has_parent boolean, p_ids uuid[]
16
+ ) returns table ("id" uuid, "fields" jsonb) language sql stable set search_path = public as $$
17
+ with mode as (
18
+ select p_draft and (current_user = 'service_role' or "smoodly_key_kind"() = 'write') as draft
19
+ ), shown as (
20
+ select e."id", e."sort", e."created_at", l."updated_at",
21
+ case when (select draft from mode) then e."fields" || l."fields" || jsonb_build_object('slug', l."slug")
22
+ else coalesce(v."fields", e."fields" || l."fields" || jsonb_build_object('slug', l."slug")) end as "fields"
23
+ from "entries" e
24
+ join "entry_locales" l on l."entry_id" = e."id" and l."locale" = p_locale
25
+ left join "entry_versions" v on v."id" = l."published_version_id"
26
+ where e."collection" = p_collection
27
+ and ((select draft from mode) or l."status" = 'published')
28
+ and (not p_has_parent or e."parent_id" is not distinct from p_parent)
29
+ and (p_ids is null or e."id" = any(p_ids))
30
+ )
31
+ select s."id", s."fields" from shown s
32
+ where not exists (
33
+ select 1 from jsonb_each(coalesce(p_where, '{}'::jsonb)) w
34
+ where not (case when w.value ? 'in'
35
+ then (s."fields" ->> w.key) = any (select jsonb_array_elements_text(w.value -> 'in'))
36
+ else s."fields" @> jsonb_build_object(w.key, w.value -> 'contains') end))
37
+ order by
38
+ case when p_order ->> 'by' = 'manual' then s."sort" end asc nulls last,
39
+ case when p_order ->> 'direction' = 'asc' then
40
+ case p_order ->> 'by' when 'createdAt' then to_jsonb(s."created_at") when 'updatedAt' then to_jsonb(s."updated_at")
41
+ when 'manual' then null else nullif(nullif(s."fields" -> (p_order ->> 'by'), 'null'::jsonb), '""'::jsonb) end end asc nulls last,
42
+ case when p_order ->> 'direction' = 'desc' then
43
+ case p_order ->> 'by' when 'createdAt' then to_jsonb(s."created_at") when 'updatedAt' then to_jsonb(s."updated_at")
44
+ when 'manual' then null else nullif(nullif(s."fields" -> (p_order ->> 'by'), 'null'::jsonb), '""'::jsonb) end end desc nulls last,
45
+ s."created_at" asc, s."id" asc
46
+ limit p_limit;
47
+ $$;
48
+
49
+ -- No public content reads (spec 2026-09-29 content API contract §8): the
50
+ -- publishable key and a read key read nothing; a write key reads its own space.
51
+ drop policy if exists "smoodly_read" on "pages";
52
+ create policy "smoodly_read" on "pages" for select
53
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
54
+
55
+ drop policy if exists "smoodly_read" on "page_locales";
56
+ create policy "smoodly_read" on "page_locales" for select
57
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
58
+
59
+ drop policy if exists "smoodly_read" on "page_versions";
60
+ create policy "smoodly_read" on "page_versions" for select
61
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
62
+
63
+ drop policy if exists "smoodly_read" on "entries";
64
+ create policy "smoodly_read" on "entries" for select
65
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
66
+
67
+ drop policy if exists "smoodly_read" on "entry_locales";
68
+ create policy "smoodly_read" on "entry_locales" for select
69
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
70
+
71
+ drop policy if exists "smoodly_read" on "entry_versions";
72
+ create policy "smoodly_read" on "entry_versions" for select
73
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
74
+
75
+ drop policy if exists "smoodly_read" on "paths";
76
+ create policy "smoodly_read" on "paths" for select
77
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
78
+
79
+ drop policy if exists "smoodly_read" on "assets";
80
+ create policy "smoodly_read" on "assets" for select
81
+ using ("space_id" = (select "smoodly_current_space"()) and not (select "smoodly_space_key_revoked"()) and (select "smoodly_key_kind"()) = 'write');
82
+
83
+ insert into "smoodly_meta" ("key", "value") values ('schema_version', '7')
84
+ on conflict ("key") do update set "value" = excluded."value";
@@ -1,8 +1,8 @@
1
- -- Smoodly: read views and order indexes for this app's collections, written by `npx smoodly migrate`
2
- -- (2026-09-29T13:56:23.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
1
+ -- Smoodly: read views for this app's collections, written by `npx smoodly migrate`
2
+ -- (2026-09-30T04:10:56.000Z). One block per collection; the marker's hash is the block's SQL, compared on the next run.
3
3
  -- Never edit a written file: change the collection and run migrate again.
4
4
 
5
- -- smoodly:collection posts sha256:2e648b887b8e7146
5
+ -- smoodly:collection posts sha256:38ba2918f83ab367
6
6
  create or replace view "posts" with (security_invoker = true) as
7
7
  select
8
8
  e."id",
@@ -18,6 +18,3 @@ from "entries" e
18
18
  join "entry_locales" l on l."entry_id" = e."id"
19
19
  left join "entry_versions" v on v."id" = l."published_version_id"
20
20
  where e."collection" = 'posts' and l."status" = 'published';
21
-
22
- create index if not exists "entries_posts_date_idx"
23
- on "entries" (("fields"->'date')) where "collection" = 'posts';
@@ -21,7 +21,7 @@ export const metadata = { metadataBase: new URL(process.env.SITE_URL || "http://
21
21
  // renders it through components/PageFrame.tsx, the same file that carries
22
22
  // the language links in a multilingual site (spec 2026-09-15).
23
23
  export default async function RootLayout({ children }: { children: ReactNode }) {
24
- const [footerProps, contactFields] = await Promise.all([
24
+ const [footer, contact] = await Promise.all([
25
25
  q().getGlobal("footer"),
26
26
  q().getGlobal("contact"),
27
27
  ]);
@@ -29,7 +29,7 @@ export default async function RootLayout({ children }: { children: ReactNode })
29
29
  <html lang="en" className={`${serif.variable} ${sans.variable}`}>
30
30
  <body>
31
31
  {children}
32
- {footerProps && <FooterView {...footerProps} contact={contactFields} />}
32
+ {footer && <FooterView {...footer.fields} settings={footer.settings} styles={footer.styles} contact={contact?.fields} />}
33
33
  </body>
34
34
  </html>
35
35
  );
@@ -24,7 +24,7 @@ export async function PageFrame({ locale, locales, children }: {
24
24
  : undefined;
25
25
  return (
26
26
  <>
27
- {header && <HeaderView {...header} home={href("/", locale)} locales={links} />}
27
+ {header && <HeaderView {...header.fields} settings={header.settings} styles={header.styles} home={href("/", locale)} locales={links} />}
28
28
  <main>{children}</main>
29
29
  </>
30
30
  );
@@ -23,7 +23,6 @@ function segment(locale: string): string {
23
23
  }
24
24
 
25
25
  export const articlesIndexPath = (locale: string) => `/${segment(locale)}`;
26
- export const articlePath = (slug: string, locale: string) => `/${segment(locale)}/${slug}`;
27
26
 
28
27
  export const formatDate = (iso: string, locale: string) =>
29
28
  new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(new Date(iso));
@@ -10,5 +10,4 @@ function address(locale: string): string {
10
10
  return p?.[locale] ?? Object.values(p ?? {})[0] ?? "company/news";
11
11
  }
12
12
 
13
- export type NewsFields = { title: string; slug: string; date: string; excerpt?: string; body?: unknown };
14
13
  export const newsIndexPath = (locale: string) => `/${address(locale)}`;
@@ -1,11 +1,11 @@
1
- import { smoodly, type EntryPageProps } from "smoodly";
1
+ import { smoodly } from "smoodly";
2
2
  import { RichText } from "@/smoodly/richtext";
3
3
  import { SmoodlyImage } from "smoodly/image";
4
4
  import { articles } from "@/smoodly/collections";
5
5
  import { q } from "@/smoodly/server";
6
6
  import { ArticleCard } from "../ArticleCard";
7
7
  import { PageFrame } from "../PageFrame";
8
- import { articlePath, articlesIndexPath, formatDate, readingMinutes, type ArticleFields } from "../articles";
8
+ import { articlesIndexPath, formatDate, readingMinutes } from "../articles";
9
9
  import { ui } from "../strings";
10
10
 
11
11
  // The entry page for `articles`, served at the collection's `path`
@@ -13,13 +13,19 @@ import { ui } from "../strings";
13
13
  // resolved (author is a person). The body is richtext rendered by the
14
14
  // package's RichText; the read time is words / 200. "Related articles"
15
15
  // is the newest other published articles, fetched here, and absent when
16
- // there are none. The render locale and the alternates arrive as props
16
+ // there are none. The render locale and the alternates ride on the entry
17
17
  // (spec 2026-09-15); PageFrame renders the header from them.
18
- async function ArticleView({ entry, locale, locales }: EntryPageProps) {
18
+ export const ArticlePage = smoodly.entryPage(articles, async function ArticleView({ entry }) {
19
+ const { locale, locales } = entry;
19
20
  const { t, url } = await ui();
20
- const a = entry.fields as ArticleFields & { author?: { name: string; role?: string } | null };
21
+ const a = entry.fields;
21
22
  // Four newest, minus this one, so three remain even when it is among them; the store applies the limit.
22
- const related = (await q().getEntries("articles", { locale, limit: 4 })).filter((r) => r.entry.id !== entry.id).slice(0, 3);
23
+ const related = (await q().getEntries("articles", { locale, limit: 4 })).filter((r) => r.id !== entry.id).slice(0, 3);
24
+ // The author's other articles: `where` filters on the shared `author` field in the store, and reads the published rows.
25
+ const authorId = a.author?.id;
26
+ const more = authorId
27
+ ? (await q().getEntries("articles", { locale, where: { author: authorId } })).filter((r) => r.id !== entry.id)
28
+ : [];
23
29
  const index = url(articlesIndexPath(locale));
24
30
  return (
25
31
  <PageFrame locale={locale} locales={locales}>
@@ -35,8 +41,8 @@ async function ArticleView({ entry, locale, locales }: EntryPageProps) {
35
41
  <p className="article__byline">
36
42
  <span className="article__avatar" aria-hidden="true" />
37
43
  <span>
38
- {a.author?.name && <strong>{a.author.name}</strong>}
39
- {a.author?.name && " · "}
44
+ {a.author?.fields.name && <strong>{a.author.fields.name}</strong>}
45
+ {a.author?.fields.name && " · "}
40
46
  {a.date && <>{formatDate(a.date, locale)} · </>}
41
47
  {t("minRead", { minutes: readingMinutes(a.body) })}
42
48
  </span>
@@ -45,6 +51,20 @@ async function ArticleView({ entry, locale, locales }: EntryPageProps) {
45
51
  {a.image && <SmoodlyImage image={a.image} aspect="21:9" className="article__image" sizes="(min-width: 900px) 800px, 100vw" priority />}
46
52
  <div className="article__body prose prose--lead"><RichText doc={a.body} /></div>
47
53
  </article>
54
+ {more.length > 0 && (
55
+ <section className="related" data-testid="more-by-author">
56
+ <div className="container">
57
+ <div className="related__head">
58
+ <h2 className="h2">{t("moreFromAuthor", { name: a.author?.fields.name ?? "" })}</h2>
59
+ </div>
60
+ <div className="card-grid card-grid--3">
61
+ {more.map((r) => (
62
+ <ArticleCard key={r.id} article={r.fields} url={url(r.path!)} locale={locale} compact />
63
+ ))}
64
+ </div>
65
+ </div>
66
+ </section>
67
+ )}
48
68
  {related.length > 0 && (
49
69
  <section className="related">
50
70
  <div className="container">
@@ -53,16 +73,14 @@ async function ArticleView({ entry, locale, locales }: EntryPageProps) {
53
73
  <a className="link-accent" href={index}>{t("allArticles")} →</a>
54
74
  </div>
55
75
  <div className="card-grid card-grid--3">
56
- {related.map(({ entry: r, path }) => {
57
- const fields = r.fields as ArticleFields;
58
- return <ArticleCard key={r.id} article={fields} url={url(path ?? articlePath(fields.slug, locale))} locale={locale} compact />;
59
- })}
76
+ {related.map((r) => (
77
+ <ArticleCard key={r.id} article={r.fields} url={url(r.path!)} locale={locale} compact />
78
+ ))}
60
79
  </div>
61
80
  </div>
62
81
  </section>
63
82
  )}
64
83
  </PageFrame>
65
84
  );
66
- }
85
+ });
67
86
 
68
- export const ArticlePage = smoodly.entryPage(articles, ArticleView);
@@ -2,7 +2,6 @@ import { smoodly, z, Zone, type Props } from "smoodly";
2
2
  import { PageHero } from "../sections/PageHero";
3
3
  import { ArticleCard } from "../ArticleCard";
4
4
  import { PageFrame } from "../PageFrame";
5
- import { articlePath, type ArticleFields } from "../articles";
6
5
  import { ui } from "../strings";
7
6
  import { q } from "@/smoodly/server";
8
7
 
@@ -21,7 +20,7 @@ export const articlesSchema = smoodly.schema.page({
21
20
  zones: {
22
21
  hero: z.locked(PageHero),
23
22
  },
24
- meta: { seo: true },
23
+ seo: true,
25
24
  });
26
25
 
27
26
  async function ArticlesView({ zones, page }: Props<typeof articlesSchema>) {
@@ -32,10 +31,9 @@ async function ArticlesView({ zones, page }: Props<typeof articlesSchema>) {
32
31
  <Zone of={zones.hero} />
33
32
  <section className="container articles-index">
34
33
  <div className="card-grid">
35
- {items.map(({ entry, path }) => {
36
- const a = entry.fields as ArticleFields;
37
- return <ArticleCard key={entry.id} article={a} url={url(path ?? articlePath(a.slug, locale))} locale={locale} />;
38
- })}
34
+ {items.map((entry) => (
35
+ <ArticleCard key={entry.id} article={entry.fields} url={url(entry.path!)} locale={locale} />
36
+ ))}
39
37
  </div>
40
38
  </section>
41
39
  </PageFrame>
@@ -23,7 +23,7 @@ export const homeSchema = smoodly.schema.page({
23
23
  hero: z.locked(Hero),
24
24
  body: z.freeform({ sections: [ImageText, Points, FavouriteArticles, People, Quote], custom: true }),
25
25
  },
26
- meta: { seo: true },
26
+ seo: true,
27
27
  });
28
28
 
29
29
  function HomeView({ zones, page }: Props<typeof homeSchema>) {