hazo_blog 1.2.0 → 1.4.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.
Files changed (69) hide show
  1. package/CHANGE_LOG.md +87 -0
  2. package/README.md +11 -0
  3. package/dist/components/admin/featured-image-field.d.ts.map +1 -1
  4. package/dist/components/admin/featured-image-field.js +9 -4
  5. package/dist/components/admin/post-form.d.ts +4 -2
  6. package/dist/components/admin/post-form.d.ts.map +1 -1
  7. package/dist/components/admin/post-form.js +27 -18
  8. package/dist/components/author-bio.d.ts +3 -1
  9. package/dist/components/author-bio.d.ts.map +1 -1
  10. package/dist/components/author-bio.js +3 -4
  11. package/dist/components/blog-search.d.ts +3 -1
  12. package/dist/components/blog-search.d.ts.map +1 -1
  13. package/dist/components/blog-search.js +4 -5
  14. package/dist/components/editorial-post-card.d.ts +3 -1
  15. package/dist/components/editorial-post-card.d.ts.map +1 -1
  16. package/dist/components/editorial-post-card.js +2 -2
  17. package/dist/components/faq-section.d.ts +3 -1
  18. package/dist/components/faq-section.d.ts.map +1 -1
  19. package/dist/components/faq-section.js +4 -5
  20. package/dist/components/featured-post-card.d.ts +3 -1
  21. package/dist/components/featured-post-card.d.ts.map +1 -1
  22. package/dist/components/featured-post-card.js +4 -5
  23. package/dist/components/layouts/blog-index-editorial.d.ts +1 -1
  24. package/dist/components/layouts/blog-index-editorial.d.ts.map +1 -1
  25. package/dist/components/layouts/blog-index-editorial.js +6 -7
  26. package/dist/components/layouts/blog-index-grid.d.ts +1 -1
  27. package/dist/components/layouts/blog-index-grid.d.ts.map +1 -1
  28. package/dist/components/layouts/blog-index-grid.js +6 -7
  29. package/dist/components/layouts/index.d.ts +2 -0
  30. package/dist/components/layouts/index.d.ts.map +1 -1
  31. package/dist/components/mdx/youtube.js +1 -1
  32. package/dist/components/post-card.d.ts +3 -1
  33. package/dist/components/post-card.d.ts.map +1 -1
  34. package/dist/components/post-card.js +5 -5
  35. package/dist/components/post-hero.d.ts +3 -1
  36. package/dist/components/post-hero.d.ts.map +1 -1
  37. package/dist/components/post-hero.js +5 -13
  38. package/dist/components/related-posts.d.ts +3 -1
  39. package/dist/components/related-posts.d.ts.map +1 -1
  40. package/dist/components/related-posts.js +4 -5
  41. package/dist/components/table-of-contents.d.ts +3 -1
  42. package/dist/components/table-of-contents.d.ts.map +1 -1
  43. package/dist/components/table-of-contents.js +5 -5
  44. package/dist/lib/dates.d.ts +6 -1
  45. package/dist/lib/dates.d.ts.map +1 -1
  46. package/dist/lib/dates.js +14 -2
  47. package/dist/lib/i18n.d.ts +28 -0
  48. package/dist/lib/i18n.d.ts.map +1 -0
  49. package/dist/lib/i18n.js +74 -0
  50. package/dist/lib/index.d.ts +1 -0
  51. package/dist/lib/index.d.ts.map +1 -1
  52. package/dist/lib/index.js +1 -0
  53. package/dist/locales/de.json +107 -0
  54. package/dist/locales/en.json +84 -1
  55. package/dist/locales/sv.json +107 -0
  56. package/dist/next/blog-content.js +1 -1
  57. package/dist/next/pages.d.ts.map +1 -1
  58. package/dist/next/pages.js +17 -13
  59. package/dist/types/index.d.ts +8 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/ui/blog-admin-panel.d.ts.map +1 -1
  62. package/dist/ui/blog-admin-panel.js +10 -4
  63. package/dist/ui/layout-selector.d.ts.map +1 -1
  64. package/dist/ui/layout-selector.js +6 -3
  65. package/dist/ui/post-list-table.d.ts.map +1 -1
  66. package/dist/ui/post-list-table.js +9 -6
  67. package/dist/ui/post-preview.d.ts.map +1 -1
  68. package/dist/ui/post-preview.js +4 -1
  69. package/package.json +15 -15
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // <YouTube id="..." title="..." start={30} /> — privacy-friendly lazy embed.
3
3
  import { cn } from "hazo_ui/utils";
4
4
  import en from "../../locales/en.json" with { type: "json" };
5
- import { createPackageT } from "../../lib/create_package_t.js";
5
+ import { createPackageT } from "hazo_core/i18n";
6
6
  const t = createPackageT("hazo_blog", en);
7
7
  export function YouTube({ id, title = t("youtube.default_title"), start, className }) {
8
8
  const src = `https://www.youtube-nocookie.com/embed/${id}${start ? `?start=${start}` : ""}`;
@@ -3,6 +3,8 @@ export interface PostCardProps {
3
3
  post: BlogPostWithRelations;
4
4
  basePath?: string;
5
5
  className?: string;
6
+ /** UI locale for user-visible text and dates. Default "en". */
7
+ locale?: string;
6
8
  }
7
- export declare function PostCard({ post, basePath, className }: PostCardProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function PostCard({ post, basePath, className, locale }: PostCardProps): import("react/jsx-runtime").JSX.Element;
8
10
  //# sourceMappingURL=post-card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-card.d.ts","sourceRoot":"","sources":["../../src/components/post-card.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAkB,EAAE,SAAS,EAAE,EAAE,aAAa,2CAkD9E"}
1
+ {"version":3,"file":"post-card.d.ts","sourceRoot":"","sources":["../../src/components/post-card.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAkB,EAAE,SAAS,EAAE,MAAa,EAAE,EAAE,aAAa,2CAmD7F"}
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Link from "next/link";
3
3
  import Image from "next/image";
4
4
  import { cn } from "hazo_ui/utils";
5
- import en from "../locales/en.json" with { type: "json" };
6
- import { createPackageT } from "../lib/create_package_t.js";
7
- const t = createPackageT("hazo_blog", en);
8
- export function PostCard({ post, basePath = "/blog", className }) {
5
+ import { blogTranslator } from "../lib/i18n.js";
6
+ import { formatPostDate } from "../lib/dates.js";
7
+ export function PostCard({ post, basePath = "/blog", className, locale = "en" }) {
8
+ const t = blogTranslator(locale);
9
9
  return (_jsx("article", { className: cn("group overflow-hidden rounded-xl border border-border bg-card transition-shadow hover:shadow-md", className), children: _jsxs(Link, { href: `${basePath}/${post.slug}`, className: "block", children: [post.featured_image && (_jsx("div", { className: "relative aspect-video w-full overflow-hidden", children: _jsx(Image, { src: post.featured_image, alt: post.title, fill: true, className: "object-cover transition-transform duration-300 group-hover:scale-105", sizes: "(max-width: 768px) 100vw, 33vw" }) })), _jsxs("div", { className: "p-5", children: [post.category && (_jsx("span", { className: "mb-2 inline-block rounded-full px-2.5 py-0.5 text-xs font-medium", style: {
10
10
  backgroundColor: `${post.category.colour}20`,
11
11
  color: post.category.colour,
12
- }, children: post.category.name })), _jsx("h3", { className: "mb-1 line-clamp-2 text-lg font-semibold text-foreground group-hover:text-primary", children: post.title }), post.excerpt && (_jsx("p", { className: "line-clamp-2 text-sm text-muted-foreground", children: post.excerpt })), _jsxs("p", { className: "mt-3 text-xs text-muted-foreground", children: [t("post_card.reading_time", { minutes: String(post.reading_time) }), post.publish_date && (_jsxs("span", { className: "ml-2 text-muted-foreground/60", children: ["\u00B7 ", new Date(post.publish_date).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" })] }))] })] })] }) }));
12
+ }, children: post.category.name })), _jsx("h3", { className: "mb-1 line-clamp-2 text-lg font-semibold text-foreground group-hover:text-primary", children: post.title }), post.excerpt && (_jsx("p", { className: "line-clamp-2 text-sm text-muted-foreground", children: post.excerpt })), _jsxs("p", { className: "mt-3 text-xs text-muted-foreground", children: [t("post_card.reading_time", { minutes: String(post.reading_time) }), post.publish_date && (_jsxs("span", { className: "ml-2 text-muted-foreground/60", children: ["\u00B7 ", formatPostDate(post.publish_date, "short", locale)] }))] })] })] }) }));
13
13
  }
@@ -2,6 +2,8 @@ import type { BlogPostWithRelations } from "../types/index.js";
2
2
  export interface PostHeroProps {
3
3
  post: BlogPostWithRelations;
4
4
  className?: string;
5
+ /** UI locale for user-visible text and dates. Default "en". */
6
+ locale?: string;
5
7
  }
6
- export declare function PostHero({ post, className }: PostHeroProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function PostHero({ post, className, locale }: PostHeroProps): import("react/jsx-runtime").JSX.Element;
7
9
  //# sourceMappingURL=post-hero.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-hero.d.ts","sourceRoot":"","sources":["../../src/components/post-hero.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,aAAa,2CAmC1D"}
1
+ {"version":3,"file":"post-hero.d.ts","sourceRoot":"","sources":["../../src/components/post-hero.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI/D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAa,EAAE,EAAE,aAAa,2CAsCzE"}
@@ -1,20 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import Image from "next/image";
3
3
  import { cn } from "hazo_ui/utils";
4
- import en from "../locales/en.json" with { type: "json" };
5
- import { createPackageT } from "../lib/create_package_t.js";
6
- const t = createPackageT("hazo_blog", en);
7
- function formatDate(value) {
8
- if (!value)
9
- return "";
10
- const d = new Date(value);
11
- if (Number.isNaN(d.getTime()))
12
- return "";
13
- return d.toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric" });
14
- }
15
- export function PostHero({ post, className }) {
4
+ import { blogTranslator } from "../lib/i18n.js";
5
+ import { formatPostDate } from "../lib/dates.js";
6
+ export function PostHero({ post, className, locale = "en" }) {
7
+ const t = blogTranslator(locale);
16
8
  return (_jsxs("header", { className: cn("mb-8", className), children: [_jsxs("div", { className: "mb-4 flex flex-wrap items-center gap-3 text-sm text-muted-foreground", children: [post.category && (_jsx("span", { className: "rounded-full px-2.5 py-0.5 text-xs font-medium", style: {
17
9
  backgroundColor: `${post.category.colour}20`,
18
10
  color: post.category.colour,
19
- }, children: post.category.name })), post.publish_date && _jsx("time", { dateTime: post.publish_date, children: formatDate(post.publish_date) }), _jsxs("span", { children: ["\u00B7 ", t("post_hero.reading_time", { minutes: String(post.reading_time) })] })] }), _jsx("h1", { className: "text-3xl font-bold tracking-tight text-foreground sm:text-4xl", children: post.title }), post.featured_image && (_jsx("div", { className: "relative mt-6 aspect-video w-full overflow-hidden rounded-xl", children: _jsx(Image, { src: post.featured_image, alt: post.title, fill: true, priority: true, className: "object-cover", sizes: "(max-width: 768px) 100vw, 768px" }) }))] }));
11
+ }, children: post.category.name })), post.publish_date && (_jsx("time", { dateTime: post.publish_date, children: formatPostDate(post.publish_date, "long", locale) })), _jsxs("span", { children: ["\u00B7 ", t("post_hero.reading_time", { minutes: String(post.reading_time) })] })] }), _jsx("h1", { className: "text-3xl font-bold tracking-tight text-foreground sm:text-4xl", children: post.title }), post.featured_image && (_jsx("div", { className: "relative mt-6 aspect-video w-full overflow-hidden rounded-xl", children: _jsx(Image, { src: post.featured_image, alt: post.title, fill: true, priority: true, className: "object-cover", sizes: "(max-width: 768px) 100vw, 768px" }) }))] }));
20
12
  }
@@ -4,6 +4,8 @@ export interface RelatedPostsProps {
4
4
  basePath?: string;
5
5
  title?: string;
6
6
  className?: string;
7
+ /** UI locale for the default heading and card text/dates. Default "en". */
8
+ locale?: string;
7
9
  }
8
- export declare function RelatedPosts({ posts, basePath, title, className, }: RelatedPostsProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export declare function RelatedPosts({ posts, basePath, title, className, locale, }: RelatedPostsProps): import("react/jsx-runtime").JSX.Element | null;
9
11
  //# sourceMappingURL=related-posts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"related-posts.d.ts","sourceRoot":"","sources":["../../src/components/related-posts.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO/D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAkB,EAClB,KAAgC,EAChC,SAAS,GACV,EAAE,iBAAiB,kDAYnB"}
1
+ {"version":3,"file":"related-posts.d.ts","sourceRoot":"","sources":["../../src/components/related-posts.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI/D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,qBAAqB,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAkB,EAClB,KAAK,EACL,SAAS,EACT,MAAa,GACd,EAAE,iBAAiB,kDAanB"}
@@ -1,11 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from "hazo_ui/utils";
3
3
  import { PostCard } from "./post-card.js";
4
- import en from "../locales/en.json" with { type: "json" };
5
- import { createPackageT } from "../lib/create_package_t.js";
6
- const t = createPackageT("hazo_blog", en);
7
- export function RelatedPosts({ posts, basePath = "/blog", title = t("related_posts.title"), className, }) {
4
+ import { blogTranslator } from "../lib/i18n.js";
5
+ export function RelatedPosts({ posts, basePath = "/blog", title, className, locale = "en", }) {
8
6
  if (!posts || posts.length === 0)
9
7
  return null;
10
- return (_jsxs("section", { className: cn("my-10", className), children: [_jsx("h2", { className: "mb-4 text-2xl font-bold text-foreground", children: title }), _jsx("div", { className: "grid gap-5 sm:grid-cols-2 lg:grid-cols-3", children: posts.map((p) => (_jsx(PostCard, { post: p, basePath: basePath }, p.id))) })] }));
8
+ const t = blogTranslator(locale);
9
+ return (_jsxs("section", { className: cn("my-10", className), children: [_jsx("h2", { className: "mb-4 text-2xl font-bold text-foreground", children: title ?? t("related_posts.title") }), _jsx("div", { className: "grid gap-5 sm:grid-cols-2 lg:grid-cols-3", children: posts.map((p) => (_jsx(PostCard, { post: p, basePath: basePath, locale: locale }, p.id))) })] }));
11
10
  }
@@ -3,6 +3,8 @@ export interface TableOfContentsProps {
3
3
  headings: TocHeading[];
4
4
  title?: string;
5
5
  className?: string;
6
+ /** UI locale for the default heading. Default "en". */
7
+ locale?: string;
6
8
  }
7
- export declare function TableOfContents({ headings, title, className }: TableOfContentsProps): import("react/jsx-runtime").JSX.Element | null;
9
+ export declare function TableOfContents({ headings, title, className, locale }: TableOfContentsProps): import("react/jsx-runtime").JSX.Element | null;
8
10
  //# sourceMappingURL=table-of-contents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"table-of-contents.d.ts","sourceRoot":"","sources":["../../src/components/table-of-contents.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,KAAoC,EAAE,SAAS,EAAE,EAAE,oBAAoB,kDAgBlH"}
1
+ {"version":3,"file":"table-of-contents.d.ts","sourceRoot":"","sources":["../../src/components/table-of-contents.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAa,EAAE,EAAE,oBAAoB,kDAkBlG"}
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from "hazo_ui/utils";
3
- import en from "../locales/en.json" with { type: "json" };
4
- import { createPackageT } from "../lib/create_package_t.js";
5
- const t = createPackageT("hazo_blog", en);
6
- export function TableOfContents({ headings, title = t("table_of_contents.title"), className }) {
3
+ import { blogTranslator } from "../lib/i18n.js";
4
+ export function TableOfContents({ headings, title, className, locale = "en" }) {
7
5
  if (!headings || headings.length === 0)
8
6
  return null;
9
- return (_jsxs("nav", { className: cn("rounded-xl border border-border bg-muted/30 p-4 text-sm", className), "aria-label": title, children: [_jsx("p", { className: "mb-2 font-semibold text-foreground", children: title }), _jsx("ul", { className: "space-y-1", children: headings.map((h) => (_jsx("li", { className: h.depth === 3 ? "pl-4" : "", children: _jsx("a", { href: `#${h.id}`, className: "text-muted-foreground hover:text-primary", children: h.text }) }, h.id))) })] }));
7
+ const t = blogTranslator(locale);
8
+ const label = title ?? t("table_of_contents.title");
9
+ return (_jsxs("nav", { className: cn("rounded-xl border border-border bg-muted/30 p-4 text-sm", className), "aria-label": label, children: [_jsx("p", { className: "mb-2 font-semibold text-foreground", children: label }), _jsx("ul", { className: "space-y-1", children: headings.map((h) => (_jsx("li", { className: h.depth === 3 ? "pl-4" : "", children: _jsx("a", { href: `#${h.id}`, className: "text-muted-foreground hover:text-primary", children: h.text }) }, h.id))) })] }));
10
10
  }
@@ -2,8 +2,13 @@
2
2
  * Format an ISO date string for display. Returns `""` for `null`/`undefined`
3
3
  * or an unparseable date (never throws, never returns "Invalid Date").
4
4
  *
5
+ * `locale` selects the catalog AND the date conventions (see `DATE_LOCALE`), so
6
+ * a German page reads "5. Januar 2026" and a Swedish page "5 januari 2026".
7
+ * Omitted or unknown locales format as English (`"en-US"`), which is the
8
+ * pre-locale output and is kept byte-identical.
9
+ *
5
10
  * - `style: "short"` (default) → "Jan 5, 2026"
6
11
  * - `style: "long"` → "January 5, 2026"
7
12
  */
8
- export declare function formatPostDate(iso: string | null | undefined, style?: "short" | "long"): string;
13
+ export declare function formatPostDate(iso: string | null | undefined, style?: "short" | "long", locale?: string | null): string;
9
14
  //# sourceMappingURL=dates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../src/lib/dates.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAE,OAAO,GAAG,MAAgB,GAAG,MAAM,CASxG"}
1
+ {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../src/lib/dates.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,KAAK,GAAE,OAAO,GAAG,MAAgB,EACjC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,MAAM,CASR"}
package/dist/lib/dates.js CHANGED
@@ -1,20 +1,32 @@
1
1
  // hazo_blog — single post-date formatter, unifying three duplicated
2
2
  // implementations (pages.tsx, post-hero.tsx, and a third call site). Pure,
3
3
  // client-safe: no Node builtins, no next/react imports.
4
+ import { resolveBlogLocale } from "./i18n.js";
5
+ /** Intl locale used for date formatting, per shipped catalog. */
6
+ const DATE_LOCALE = {
7
+ en: "en-US",
8
+ de: "de-DE",
9
+ sv: "sv-SE",
10
+ };
4
11
  /**
5
12
  * Format an ISO date string for display. Returns `""` for `null`/`undefined`
6
13
  * or an unparseable date (never throws, never returns "Invalid Date").
7
14
  *
15
+ * `locale` selects the catalog AND the date conventions (see `DATE_LOCALE`), so
16
+ * a German page reads "5. Januar 2026" and a Swedish page "5 januari 2026".
17
+ * Omitted or unknown locales format as English (`"en-US"`), which is the
18
+ * pre-locale output and is kept byte-identical.
19
+ *
8
20
  * - `style: "short"` (default) → "Jan 5, 2026"
9
21
  * - `style: "long"` → "January 5, 2026"
10
22
  */
11
- export function formatPostDate(iso, style = "short") {
23
+ export function formatPostDate(iso, style = "short", locale) {
12
24
  if (!iso)
13
25
  return "";
14
26
  const d = new Date(iso);
15
27
  if (Number.isNaN(d.getTime()))
16
28
  return "";
17
- return d.toLocaleDateString("en-US", {
29
+ return d.toLocaleDateString(DATE_LOCALE[resolveBlogLocale(locale)], {
18
30
  year: "numeric",
19
31
  month: style,
20
32
  day: "numeric",
@@ -0,0 +1,28 @@
1
+ /** Locales with a shipped catalog. Anything else resolves to `"en"`. */
2
+ export declare const BLOG_LOCALES: readonly ["en", "de", "sv"];
3
+ export type BlogLocale = (typeof BLOG_LOCALES)[number];
4
+ export declare const DEFAULT_BLOG_LOCALE: BlogLocale;
5
+ export type BlogTranslator = ((key: string, vars?: Record<string, string | number>) => string) & {
6
+ /** True iff the key resolves (in the requested locale or English). */
7
+ has(key: string): boolean;
8
+ /** Raw, non-interpolated template for `key`, or `undefined`. */
9
+ raw(key: string): string | undefined;
10
+ };
11
+ /**
12
+ * Map an arbitrary BCP-47-ish tag onto a shipped catalog. Matches on the
13
+ * primary subtag, so `"de-AT"` → `"de"`, `"sv_SE"` → `"sv"`. Unknown tags,
14
+ * `null` and `undefined` → `"en"`.
15
+ */
16
+ export declare function resolveBlogLocale(locale?: string | null): BlogLocale;
17
+ /**
18
+ * Build a translator bound to `locale`. Cheap (no I/O, catalogs are already
19
+ * bundled), so call it per render rather than caching at module scope.
20
+ */
21
+ export declare function blogTranslator(locale?: string | null): BlogTranslator;
22
+ /**
23
+ * Plural suffix for the one catalog key that needs it (`common.results_count`,
24
+ * where the template reads `result{{plural}}`). English and German inflect by
25
+ * appending a suffix; Swedish "resultat" is invariant in the plural.
26
+ */
27
+ export declare function pluralSuffix(locale: string | null | undefined, count: number): string;
28
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/lib/i18n.ts"],"names":[],"mappings":"AAiBA,wEAAwE;AACxE,eAAO,MAAM,YAAY,6BAA8B,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,eAAO,MAAM,mBAAmB,EAAE,UAAiB,CAAC;AAIpD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG;IAC/F,sEAAsE;IACtE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,gEAAgE;IAChE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAMpE;AAaD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,CAcrE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUrF"}
@@ -0,0 +1,74 @@
1
+ // hazo_blog — per-render translator for user-visible strings.
2
+ //
3
+ // Why not `createPackageT` (hazo_core/i18n): it bundles ONE flat catalog and
4
+ // has no synchronous "current locale" getter, so every string it returns is
5
+ // English regardless of the page's locale. Components here instead take an
6
+ // optional `locale` prop and call `blogTranslator(locale)` on each render,
7
+ // which selects the matching catalog from `src/locales/<locale>.json`.
8
+ //
9
+ // Lookup order: requested locale → English → the key itself. Interpolation is
10
+ // the same `{{var}}` mustache form hazo_core uses (unknown vars are left as-is).
11
+ //
12
+ // Pure and client-safe: JSON imports only, no Node builtins, no React/next.
13
+ import en from "../locales/en.json" with { type: "json" };
14
+ import de from "../locales/de.json" with { type: "json" };
15
+ import sv from "../locales/sv.json" with { type: "json" };
16
+ /** Locales with a shipped catalog. Anything else resolves to `"en"`. */
17
+ export const BLOG_LOCALES = ["en", "de", "sv"];
18
+ export const DEFAULT_BLOG_LOCALE = "en";
19
+ const CATALOGS = { en, de, sv };
20
+ /**
21
+ * Map an arbitrary BCP-47-ish tag onto a shipped catalog. Matches on the
22
+ * primary subtag, so `"de-AT"` → `"de"`, `"sv_SE"` → `"sv"`. Unknown tags,
23
+ * `null` and `undefined` → `"en"`.
24
+ */
25
+ export function resolveBlogLocale(locale) {
26
+ if (!locale)
27
+ return DEFAULT_BLOG_LOCALE;
28
+ const primary = locale.trim().toLowerCase().split(/[-_]/)[0];
29
+ return BLOG_LOCALES.includes(primary)
30
+ ? primary
31
+ : DEFAULT_BLOG_LOCALE;
32
+ }
33
+ function interpolate(template, vars) {
34
+ if (!vars)
35
+ return template;
36
+ return template.replace(/\{\{\s*(\w+)\s*\}\}/g, (whole, name) => Object.prototype.hasOwnProperty.call(vars, name) ? String(vars[name]) : whole);
37
+ }
38
+ function lookup(catalog, key) {
39
+ return Object.prototype.hasOwnProperty.call(catalog, key) ? catalog[key] : undefined;
40
+ }
41
+ /**
42
+ * Build a translator bound to `locale`. Cheap (no I/O, catalogs are already
43
+ * bundled), so call it per render rather than caching at module scope.
44
+ */
45
+ export function blogTranslator(locale) {
46
+ const primary = CATALOGS[resolveBlogLocale(locale)];
47
+ const resolve = (key) => lookup(primary, key) ?? lookup(en, key);
48
+ const t = ((key, vars) => {
49
+ const template = resolve(key);
50
+ if (template === undefined)
51
+ return key;
52
+ return interpolate(template, vars);
53
+ });
54
+ t.has = (key) => typeof resolve(key) === "string";
55
+ t.raw = (key) => resolve(key);
56
+ return t;
57
+ }
58
+ /**
59
+ * Plural suffix for the one catalog key that needs it (`common.results_count`,
60
+ * where the template reads `result{{plural}}`). English and German inflect by
61
+ * appending a suffix; Swedish "resultat" is invariant in the plural.
62
+ */
63
+ export function pluralSuffix(locale, count) {
64
+ if (count === 1)
65
+ return "";
66
+ switch (resolveBlogLocale(locale)) {
67
+ case "de":
68
+ return "se";
69
+ case "sv":
70
+ return "";
71
+ default:
72
+ return "s";
73
+ }
74
+ }
@@ -2,4 +2,5 @@ export * from "./text.js";
2
2
  export * from "./validate.js";
3
3
  export * from "./dates.js";
4
4
  export * from "./layouts.js";
5
+ export * from "./i18n.js";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
package/dist/lib/index.js CHANGED
@@ -3,3 +3,4 @@ export * from "./text.js";
3
3
  export * from "./validate.js";
4
4
  export * from "./dates.js";
5
5
  export * from "./layouts.js";
6
+ export * from "./i18n.js";
@@ -0,0 +1,107 @@
1
+ {
2
+ "common.default_blog_title": "Blog",
3
+ "common.results_count": "{{count}} Ergebnis{{plural}} für „{{query}}“",
4
+ "common.clear": "Löschen",
5
+ "common.no_results_for_query": "Keine Beiträge gefunden für „{{query}}“.",
6
+ "common.no_posts_yet": "Noch keine Beiträge.",
7
+ "blog_search.placeholder": "Beiträge durchsuchen…",
8
+ "post_card.reading_time": "{{minutes}} Min. Lesezeit",
9
+ "featured_post_card.reading_time": "{{minutes}} Min. Lesezeit",
10
+ "featured_post_card.read_aria": "{{title}} lesen",
11
+ "related_posts.title": "Ähnliche Beiträge",
12
+ "table_of_contents.title": "Auf dieser Seite",
13
+ "post_hero.reading_time": "{{minutes}} Min. Lesezeit",
14
+ "faq_section.title": "Häufig gestellte Fragen",
15
+ "author_bio.written_by": "Geschrieben von",
16
+ "youtube.default_title": "YouTube-Video",
17
+ "blog_content.render_error": "Dieser Inhalt konnte nicht angezeigt werden.",
18
+ "post_page.not_found_title": "Nicht gefunden",
19
+ "index_page.meta_title": "Blog | {{siteName}}",
20
+ "index_page.meta_description": "Artikel und Anleitungen von {{siteName}}.",
21
+ "tag_page.heading_prefix": "Schlagwort:",
22
+ "tag_page.no_posts": "Keine Beiträge mit diesem Schlagwort.",
23
+ "tag_page.meta_title": "{{tag}} | {{siteName}} Blog",
24
+ "post_form.title_label": "Titel",
25
+ "post_form.title_placeholder": "Beitragstitel",
26
+ "post_form.slug_label": "Slug",
27
+ "post_form.slug_placeholder": "automatisch-aus-dem-titel",
28
+ "post_form.content_label": "Inhalt (MDX)",
29
+ "post_form.content_placeholder": "Schreibe deinen Beitrag in Markdown / MDX…",
30
+ "post_form.category_label": "Kategorie",
31
+ "post_form.category_none_option": "— keine —",
32
+ "post_form.tags_label": "Schlagwörter (kommagetrennt)",
33
+ "post_form.tags_placeholder": "anleitungen, timer",
34
+ "post_form.locale_label": "Sprache",
35
+ "post_form.locale_placeholder": "z. B. fr, pt-BR (leer = Standardsprache)",
36
+ "post_form.translation_of_label": "Übersetzung von (Beitrags-ID)",
37
+ "post_form.translation_of_placeholder": "Leer lassen für den Hauptbeitrag",
38
+ "post_form.indexable_label": "Indexierbar (in Sitemap/robots aufnehmen)",
39
+ "post_form.meta_title_label": "Meta-Titel (SEO)",
40
+ "post_form.meta_description_label": "Meta-Beschreibung (SEO)",
41
+ "post_form.faq_legend": "FAQ",
42
+ "post_form.faq_question_placeholder": "Frage",
43
+ "post_form.faq_answer_placeholder": "Antwort",
44
+ "post_form.faq_add_item": "+ FAQ-Eintrag hinzufügen",
45
+ "post_form.save_failed_with_status": "Speichern fehlgeschlagen ({{status}})",
46
+ "post_form.save_failed": "Speichern fehlgeschlagen",
47
+ "post_form.cancel": "Abbrechen",
48
+ "post_form.save_draft": "Entwurf speichern",
49
+ "post_form.saving": "Speichern…",
50
+ "post_form.publish": "Veröffentlichen",
51
+ "featured_image_field.label": "Titelbild",
52
+ "featured_image_field.alt_text": "Titelbild",
53
+ "featured_image_field.clear": "Entfernen",
54
+ "featured_image_field.upload_failed": "Hochladen fehlgeschlagen – versuche es erneut oder füge unten eine URL ein.",
55
+ "featured_image_field.drag_drop_or": "Bild hierher ziehen oder",
56
+ "featured_image_field.no_image_set": "Kein Bild gesetzt – füge unten eine URL ein",
57
+ "featured_image_field.upload": "Hochladen",
58
+ "featured_image_field.uploading": "Wird hochgeladen…",
59
+ "featured_image_field.url_placeholder": "https://…",
60
+ "blog_admin_panel.posts_heading": "Beiträge",
61
+ "blog_admin_panel.new_post_button": "Neuer Beitrag",
62
+ "blog_admin_panel.error_prefix": "Fehler: {{message}}",
63
+ "blog_admin_panel.loading_posts": "Beiträge werden geladen…",
64
+ "blog_admin_panel.index_layout_heading": "Index-Layout",
65
+ "blog_admin_panel.edit_post_title": "Beitrag bearbeiten",
66
+ "blog_admin_panel.new_post_title": "Neuer Beitrag",
67
+ "blog_admin_panel.hide_preview": "Vorschau ausblenden",
68
+ "blog_admin_panel.preview": "Vorschau",
69
+ "blog_admin_panel.delete_confirm": "„{{title}}“ löschen? Dies kann nicht rückgängig gemacht werden.",
70
+ "blog_admin_panel.delete_failed": "Löschen fehlgeschlagen",
71
+ "post_list_table.search_placeholder": "Titel oder Slug suchen…",
72
+ "post_list_table.filter_all": "Alle",
73
+ "post_list_table.filter_draft": "Entwurf",
74
+ "post_list_table.filter_published": "Veröffentlicht",
75
+ "post_list_table.filter_scheduled": "Geplant",
76
+ "post_list_table.col_title": "Titel",
77
+ "post_list_table.col_status": "Status",
78
+ "post_list_table.col_category": "Kategorie",
79
+ "post_list_table.col_published": "Veröffentlicht",
80
+ "post_list_table.no_posts_found": "Keine Beiträge gefunden.",
81
+ "post_list_table.untitled": "(ohne Titel)",
82
+ "post_list_table.edit": "Bearbeiten",
83
+ "post_list_table.delete": "Löschen",
84
+ "layout_selector.not_persisted_notice": "Einstellungstabelle nicht migriert – Layout ist schreibgeschützt.",
85
+ "layout_selector.save_failed": "Layout konnte nicht gespeichert werden",
86
+ "layout_selector.saving": "Speichern…",
87
+ "layout_selector.active": "Aktiv",
88
+ "post_preview.heading": "Veröffentlichte Vorschau",
89
+ "post_preview.open_in_new_tab": "In neuem Tab öffnen",
90
+ "post_preview.loading": "Vorschau wird geladen…",
91
+ "post_preview.iframe_title": "Beitragsvorschau",
92
+ "post_form.embed_youtube_label": "YT",
93
+ "post_form.embed_note_label": "Notiz",
94
+ "post_form.embed_image_label": "Bild",
95
+ "post_status.draft": "Entwurf",
96
+ "post_status.published": "Veröffentlicht",
97
+ "post_status.scheduled": "Geplant",
98
+ "admin_pages.list_heading": "Blog-Beiträge",
99
+ "admin_pages.new_post_button": "+ Neuer Beitrag",
100
+ "admin_pages.col_title": "Titel",
101
+ "admin_pages.col_status": "Status",
102
+ "admin_pages.col_published": "Veröffentlicht",
103
+ "admin_pages.col_slug": "Slug",
104
+ "admin_pages.edit": "Bearbeiten",
105
+ "admin_pages.new_heading": "Neuer Beitrag",
106
+ "admin_pages.edit_heading": "Bearbeiten: {{title}}"
107
+ }
@@ -20,5 +20,88 @@
20
20
  "index_page.meta_description": "Articles and guides from {{siteName}}.",
21
21
  "tag_page.heading_prefix": "Tagged:",
22
22
  "tag_page.no_posts": "No posts with this tag.",
23
- "tag_page.meta_title": "{{tag}} | {{siteName}} Blog"
23
+ "tag_page.meta_title": "{{tag}} | {{siteName}} Blog",
24
+ "post_form.title_label": "Title",
25
+ "post_form.title_placeholder": "Post title",
26
+ "post_form.slug_label": "Slug",
27
+ "post_form.slug_placeholder": "auto-generated-from-title",
28
+ "post_form.content_label": "Content (MDX)",
29
+ "post_form.content_placeholder": "Write your post in Markdown / MDX…",
30
+ "post_form.category_label": "Category",
31
+ "post_form.category_none_option": "— none —",
32
+ "post_form.tags_label": "Tags (comma-separated)",
33
+ "post_form.tags_placeholder": "guides, timers",
34
+ "post_form.locale_label": "Locale",
35
+ "post_form.locale_placeholder": "e.g. fr, pt-BR (blank = default locale)",
36
+ "post_form.translation_of_label": "Translation of (post ID)",
37
+ "post_form.translation_of_placeholder": "Leave blank for the root post",
38
+ "post_form.indexable_label": "Indexable (include in sitemap/robots)",
39
+ "post_form.meta_title_label": "Meta title (SEO)",
40
+ "post_form.meta_description_label": "Meta description (SEO)",
41
+ "post_form.faq_legend": "FAQ",
42
+ "post_form.faq_question_placeholder": "Question",
43
+ "post_form.faq_answer_placeholder": "Answer",
44
+ "post_form.faq_add_item": "+ Add FAQ item",
45
+ "post_form.save_failed_with_status": "Save failed ({{status}})",
46
+ "post_form.save_failed": "Save failed",
47
+ "post_form.cancel": "Cancel",
48
+ "post_form.save_draft": "Save draft",
49
+ "post_form.saving": "Saving…",
50
+ "post_form.publish": "Publish",
51
+ "featured_image_field.label": "Featured image",
52
+ "featured_image_field.alt_text": "Featured",
53
+ "featured_image_field.clear": "Clear",
54
+ "featured_image_field.upload_failed": "Upload failed — try again or paste a URL below.",
55
+ "featured_image_field.drag_drop_or": "Drag & drop an image, or",
56
+ "featured_image_field.no_image_set": "No image set — paste a URL below",
57
+ "featured_image_field.upload": "Upload",
58
+ "featured_image_field.uploading": "Uploading…",
59
+ "featured_image_field.url_placeholder": "https://…",
60
+ "blog_admin_panel.posts_heading": "Posts",
61
+ "blog_admin_panel.new_post_button": "New Post",
62
+ "blog_admin_panel.error_prefix": "Error: {{message}}",
63
+ "blog_admin_panel.loading_posts": "Loading posts…",
64
+ "blog_admin_panel.index_layout_heading": "Index Layout",
65
+ "blog_admin_panel.edit_post_title": "Edit Post",
66
+ "blog_admin_panel.new_post_title": "New Post",
67
+ "blog_admin_panel.hide_preview": "Hide preview",
68
+ "blog_admin_panel.preview": "Preview",
69
+ "blog_admin_panel.delete_confirm": "Delete \"{{title}}\"? This cannot be undone.",
70
+ "blog_admin_panel.delete_failed": "Delete failed",
71
+ "post_list_table.search_placeholder": "Search title or slug…",
72
+ "post_list_table.filter_all": "All",
73
+ "post_list_table.filter_draft": "Draft",
74
+ "post_list_table.filter_published": "Published",
75
+ "post_list_table.filter_scheduled": "Scheduled",
76
+ "post_list_table.col_title": "Title",
77
+ "post_list_table.col_status": "Status",
78
+ "post_list_table.col_category": "Category",
79
+ "post_list_table.col_published": "Published",
80
+ "post_list_table.no_posts_found": "No posts found.",
81
+ "post_list_table.untitled": "(untitled)",
82
+ "post_list_table.edit": "Edit",
83
+ "post_list_table.delete": "Delete",
84
+ "layout_selector.not_persisted_notice": "Settings table not migrated — layout is read-only.",
85
+ "layout_selector.save_failed": "Failed to save layout",
86
+ "layout_selector.saving": "Saving…",
87
+ "layout_selector.active": "Active",
88
+ "post_preview.heading": "Published preview",
89
+ "post_preview.open_in_new_tab": "Open in new tab",
90
+ "post_preview.loading": "Loading preview…",
91
+ "post_preview.iframe_title": "Post preview",
92
+ "post_form.embed_youtube_label": "YT",
93
+ "post_form.embed_note_label": "Note",
94
+ "post_form.embed_image_label": "Img",
95
+ "post_status.draft": "Draft",
96
+ "post_status.published": "Published",
97
+ "post_status.scheduled": "Scheduled",
98
+ "admin_pages.list_heading": "Blog posts",
99
+ "admin_pages.new_post_button": "+ New post",
100
+ "admin_pages.col_title": "Title",
101
+ "admin_pages.col_status": "Status",
102
+ "admin_pages.col_published": "Published",
103
+ "admin_pages.col_slug": "Slug",
104
+ "admin_pages.edit": "Edit",
105
+ "admin_pages.new_heading": "New post",
106
+ "admin_pages.edit_heading": "Edit: {{title}}"
24
107
  }