@canopy-iiif/app 0.8.3 → 0.8.5

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 (36) hide show
  1. package/lib/build/build.js +2 -0
  2. package/lib/build/dev.js +38 -22
  3. package/lib/build/iiif.js +359 -83
  4. package/lib/build/mdx.js +12 -2
  5. package/lib/build/pages.js +15 -1
  6. package/lib/build/styles.js +53 -1
  7. package/lib/common.js +28 -6
  8. package/lib/components/navigation.js +308 -0
  9. package/lib/page-context.js +14 -0
  10. package/lib/search/search-app.jsx +177 -25
  11. package/lib/search/search-form-runtime.js +126 -19
  12. package/lib/search/search.js +130 -18
  13. package/package.json +4 -1
  14. package/ui/dist/index.mjs +204 -101
  15. package/ui/dist/index.mjs.map +4 -4
  16. package/ui/dist/server.mjs +167 -59
  17. package/ui/dist/server.mjs.map +4 -4
  18. package/ui/styles/_variables.scss +1 -0
  19. package/ui/styles/base/_common.scss +27 -5
  20. package/ui/styles/base/_heading.scss +2 -4
  21. package/ui/styles/base/index.scss +1 -0
  22. package/ui/styles/components/_card.scss +47 -4
  23. package/ui/styles/components/_sub-navigation.scss +76 -0
  24. package/ui/styles/components/header/_header.scss +1 -4
  25. package/ui/styles/components/header/_logo.scss +33 -10
  26. package/ui/styles/components/index.scss +1 -0
  27. package/ui/styles/components/search/_filters.scss +5 -7
  28. package/ui/styles/components/search/_form.scss +55 -17
  29. package/ui/styles/components/search/_results.scss +49 -14
  30. package/ui/styles/index.css +344 -56
  31. package/ui/styles/index.scss +2 -4
  32. package/ui/tailwind-canopy-iiif-plugin.js +10 -2
  33. package/ui/tailwind-canopy-iiif-preset.js +21 -19
  34. package/ui/theme.js +303 -0
  35. package/ui/styles/variables.emit.scss +0 -72
  36. package/ui/styles/variables.scss +0 -76
@@ -20,6 +20,7 @@ const { ensureStyles } = require("./styles");
20
20
  const { copyAssets } = require("./assets");
21
21
  const { logLine } = require("./log");
22
22
  const { verifyBuildOutput } = require("./verify");
23
+ const navigation = require("../components/navigation");
23
24
 
24
25
  // hold records between builds if skipping IIIF
25
26
  let iiifRecordsCache = [];
@@ -41,6 +42,7 @@ async function build(options = {}) {
41
42
  });
42
43
  logLine("• Reset MDX cache", "blue", { dim: true });
43
44
  mdx?.resetMdxCaches();
45
+ navigation?.resetNavigationCache?.();
44
46
  if (!skipIiif) {
45
47
  await cleanDir(OUT_DIR);
46
48
  logLine(`• Cleaned output directory`, "blue", { dim: true });
package/lib/build/dev.js CHANGED
@@ -617,29 +617,45 @@ function startServer() {
617
617
  }
618
618
  if (pathname === "/") pathname = "/index.html";
619
619
 
620
- // Resolve candidate paths in order:
621
- // 1) as-is
622
- // 2) add .html for extensionless
623
- // 3) if a directory, use its index.html
624
- let filePath = null;
625
- const candidateA = path.join(OUT_DIR, pathname);
626
- const candidateB = path.join(OUT_DIR, pathname + ".html");
627
- if (fs.existsSync(candidateA)) {
628
- filePath = candidateA;
629
- } else if (fs.existsSync(candidateB)) {
630
- filePath = candidateB;
620
+ function toSitePath(p) {
621
+ const rel = p.startsWith("/") ? `.${p}` : p;
622
+ return path.resolve(OUT_DIR, rel);
631
623
  }
632
- if (!filePath) {
633
- // Try directory index for extensionless or folder routes
634
- const maybeDir = path.join(OUT_DIR, pathname);
635
- if (fs.existsSync(maybeDir)) {
636
- try {
637
- const st = fs.statSync(maybeDir);
638
- if (st.isDirectory()) {
639
- const idx = path.join(maybeDir, "index.html");
640
- if (fs.existsSync(idx)) filePath = idx;
641
- }
642
- } catch (_) {}
624
+
625
+ const ensureLeadingSlash = (p) => (p.startsWith("/") ? p : `/${p}`);
626
+ const basePath = ensureLeadingSlash(pathname);
627
+ const noTrailing = basePath !== "/" ? basePath.replace(/\/+$/, "") : basePath;
628
+ const attempts = [];
629
+
630
+ const primaryPath = noTrailing === "/" ? "/index.html" : noTrailing;
631
+ attempts.push(toSitePath(primaryPath));
632
+
633
+ if (!/\.html$/i.test(primaryPath)) {
634
+ attempts.push(toSitePath(`${primaryPath}.html`));
635
+ }
636
+
637
+ const withoutHtml = primaryPath.replace(/\.html$/i, "");
638
+ attempts.push(toSitePath(`${withoutHtml}/index.html`));
639
+
640
+ let filePath = null;
641
+ for (const candidate of attempts) {
642
+ if (!candidate) continue;
643
+ let stat;
644
+ try {
645
+ stat = fs.statSync(candidate);
646
+ } catch (_) {
647
+ continue;
648
+ }
649
+ if (stat.isFile()) {
650
+ filePath = candidate;
651
+ break;
652
+ }
653
+ if (stat.isDirectory()) {
654
+ const idx = path.join(candidate, "index.html");
655
+ if (fs.existsSync(idx)) {
656
+ filePath = idx;
657
+ break;
658
+ }
643
659
  }
644
660
  }
645
661
  if (!filePath) {