blume 0.1.3 → 0.1.4

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/cli/index.js CHANGED
@@ -2716,6 +2716,11 @@ var uiStringsObject = z.object({
2716
2716
  label: z.string().default("Language"),
2717
2717
  untranslated: z.string().default("Not translated")
2718
2718
  }).default({}),
2719
+ notFound: z.object({
2720
+ description: z.string().default("We couldn't find the page you're looking for."),
2721
+ home: z.string().default("Back to home"),
2722
+ title: z.string().default("Page not found")
2723
+ }).default({}),
2719
2724
  page: z.object({
2720
2725
  lastUpdated: z.string().default("Last updated on"),
2721
2726
  next: z.string().default("Next"),
@@ -4035,6 +4040,44 @@ const canonical = base ? base + "/changelog" : null;
4035
4040
  </RootLayout>
4036
4041
  `;
4037
4042
  };
4043
+ var notFoundPageTemplate = () => `---
4044
+ // Generated by Blume. Do not edit. Override by adding \`pages/404.astro\`.
4045
+ import PageLayout from "blume/components/layout/PageLayout.astro";
4046
+ import data from "../generated/data.json";
4047
+
4048
+ export const prerender = true;
4049
+
4050
+ const nf = data.ui.notFound;
4051
+ ---
4052
+
4053
+ <PageLayout
4054
+ site={{ title: data.config.title, description: data.config.description }}
4055
+ logo={data.config.logo}
4056
+ favicon={data.config.favicon}
4057
+ appleIcon={data.config.appleIcon}
4058
+ banner={data.config.banner}
4059
+ analytics={data.config.analytics}
4060
+ navigation={data.navigation}
4061
+ page={{ title: nf.title, route: "/404" }}
4062
+ themeMode={data.config.theme.mode}
4063
+ fontCssVars={data.fontCssVars}
4064
+ searchEnabled={data.config.search.enabled}
4065
+ ui={data.ui}
4066
+ noindex={true}
4067
+ >
4068
+ <div
4069
+ class="mx-auto flex min-h-[60vh] max-w-2xl flex-col items-center justify-center gap-4 px-6 py-24 text-center"
4070
+ >
4071
+ <p class="text-6xl font-bold text-muted-foreground">404</p>
4072
+ <h1 class="text-2xl font-semibold text-foreground">{nf.title}</h1>
4073
+ <p class="text-muted-foreground">{nf.description}</p>
4074
+ <a
4075
+ class="mt-2 rounded-md bg-accent px-4 py-2 text-sm font-medium text-accent-foreground"
4076
+ href="/">{nf.home}</a
4077
+ >
4078
+ </div>
4079
+ </PageLayout>
4080
+ `;
4038
4081
  var userComponentsTemplate = (componentsFile) => {
4039
4082
  if (!componentsFile) {
4040
4083
  return `// Generated by Blume. Do not edit.
@@ -5182,6 +5225,7 @@ var discoverPages = async (pagesRoot) => {
5182
5225
  return { entrypoint: file, pattern };
5183
5226
  });
5184
5227
  };
5228
+ var routeIsTaken = (pages, contentPages, route) => pages.some((page) => page.pattern === route) || contentPages.some((page) => page.route === route);
5185
5229
  var PRIVATE_SEGMENT = /^[._]/u;
5186
5230
  var humanizeSegment = (segment) => segment.split(/[-_]/u).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
5187
5231
  var customOgRoutes = (pages, siteTitle, siteDescription) => {
@@ -5593,6 +5637,12 @@ var writeMcpFiles = async (project, plan, write) => {
5593
5637
  write(join11(plan.dir, "server-card.ts"), staticJsonEndpointTemplate(buildMcpServerCard(discoveryInput)))
5594
5638
  ]);
5595
5639
  };
5640
+ var writeNotFoundPage = async (write, srcDir, pages, contentPages) => {
5641
+ if (routeIsTaken(pages, contentPages, "/404")) {
5642
+ return;
5643
+ }
5644
+ await write(join11(srcDir, "pages", "404.astro"), notFoundPageTemplate());
5645
+ };
5596
5646
  var generateRuntime = async (project) => {
5597
5647
  const { context, config } = project;
5598
5648
  const out = context.outDir;
@@ -5681,6 +5731,7 @@ var generateRuntime = async (project) => {
5681
5731
  if (hasChangelog && !changelogRouteTaken) {
5682
5732
  await write(join11(srcDir, "pages", "changelog.astro"), changelogIndexTemplate({ askEnabled, exportEpub, exportPdf }));
5683
5733
  }
5734
+ await writeNotFoundPage(write, srcDir, pages, project.graph.pages);
5684
5735
  await write(searchClientPath, searchClientTemplate(config));
5685
5736
  if (servesStaticIndex(config.search.provider)) {
5686
5737
  const documents = await buildSearchDocuments(project);
@@ -7366,7 +7417,8 @@ var toNavNode = (node) => {
7366
7417
  display: node.display,
7367
7418
  icon: node.icon,
7368
7419
  kind: "group",
7369
- label: node.label
7420
+ label: node.label,
7421
+ path: node.routePath
7370
7422
  };
7371
7423
  };
7372
7424
  var buildFileSystemSidebar = (pages, folderMeta, sharedMeta, metaPrefix) => {
@@ -7378,9 +7430,12 @@ var buildFileSystemSidebar = (pages, folderMeta, sharedMeta, metaPrefix) => {
7378
7430
  const parts = page.navPath.split("/");
7379
7431
  const filename = parts.at(-1) ?? page.navPath;
7380
7432
  const dirs = parts.slice(0, -1);
7433
+ const folderParts = page.route.split("/").filter(Boolean).slice(0, -1);
7434
+ const offset = Math.max(0, folderParts.length - dirs.length);
7381
7435
  let parent = root;
7382
- for (const dir of dirs) {
7436
+ for (const [index, dir] of dirs.entries()) {
7383
7437
  parent = ensureGroup(parent, dir);
7438
+ parent.routePath ??= `/${folderParts.slice(0, offset + index + 1).join("/")}`;
7384
7439
  }
7385
7440
  parent.children.push({
7386
7441
  badge: page.meta.sidebar.badge,
@@ -10192,6 +10247,12 @@ var eject = async (root) => {
10192
10247
  path: join24(srcDir, "pages", "og", "[...slug].png.ts")
10193
10248
  });
10194
10249
  }
10250
+ if (!routeIsTaken(pages, project.graph.pages, "/404")) {
10251
+ files.push({
10252
+ content: notFoundPageTemplate(),
10253
+ path: join24(srcDir, "pages", "404.astro")
10254
+ });
10255
+ }
10195
10256
  files.push({
10196
10257
  content: searchClientTemplate(config),
10197
10258
  path: join24(genDir, "search-client.ts")
@@ -12739,5 +12800,5 @@ var main = defineCommand11({
12739
12800
  });
12740
12801
  runMain(main);
12741
12802
 
12742
- //# debugId=55EFB0DA63E08C3864756E2164756E21
12803
+ //# debugId=A553178EDDFDE46E64756E2164756E21
12743
12804
  //# sourceMappingURL=index.js.map