@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.
- package/lib/build/build.js +2 -0
- package/lib/build/dev.js +38 -22
- package/lib/build/iiif.js +359 -83
- package/lib/build/mdx.js +12 -2
- package/lib/build/pages.js +15 -1
- package/lib/build/styles.js +53 -1
- package/lib/common.js +28 -6
- package/lib/components/navigation.js +308 -0
- package/lib/page-context.js +14 -0
- package/lib/search/search-app.jsx +177 -25
- package/lib/search/search-form-runtime.js +126 -19
- package/lib/search/search.js +130 -18
- package/package.json +4 -1
- package/ui/dist/index.mjs +204 -101
- package/ui/dist/index.mjs.map +4 -4
- package/ui/dist/server.mjs +167 -59
- package/ui/dist/server.mjs.map +4 -4
- package/ui/styles/_variables.scss +1 -0
- package/ui/styles/base/_common.scss +27 -5
- package/ui/styles/base/_heading.scss +2 -4
- package/ui/styles/base/index.scss +1 -0
- package/ui/styles/components/_card.scss +47 -4
- package/ui/styles/components/_sub-navigation.scss +76 -0
- package/ui/styles/components/header/_header.scss +1 -4
- package/ui/styles/components/header/_logo.scss +33 -10
- package/ui/styles/components/index.scss +1 -0
- package/ui/styles/components/search/_filters.scss +5 -7
- package/ui/styles/components/search/_form.scss +55 -17
- package/ui/styles/components/search/_results.scss +49 -14
- package/ui/styles/index.css +344 -56
- package/ui/styles/index.scss +2 -4
- package/ui/tailwind-canopy-iiif-plugin.js +10 -2
- package/ui/tailwind-canopy-iiif-preset.js +21 -19
- package/ui/theme.js +303 -0
- package/ui/styles/variables.emit.scss +0 -72
- package/ui/styles/variables.scss +0 -76
package/lib/build/build.js
CHANGED
|
@@ -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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
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
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
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) {
|