@iyulab/canopy-page 0.12.0 → 0.13.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.
- package/CHANGELOG.md +18 -0
- package/README.md +12 -2
- package/dist/assets/search.css +38 -0
- package/dist/assets/search.js +13 -0
- package/dist/check.d.ts +12 -0
- package/dist/check.js +52 -0
- package/dist/vault.d.ts +18 -0
- package/dist/vault.js +1 -1
- package/dist/watch.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ Notable changes to canopy-page. The format follows
|
|
|
7
7
|
The `settings.json` contract is what consuming projects plan their upgrades around, so changes
|
|
8
8
|
to it — its fields, its validation, and what the checks reject — are what this file is about.
|
|
9
9
|
|
|
10
|
+
## [0.13.0] — 2026-08-22
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Upgraded to canopy 0.12.0** — an external-link icon on `home` when it points outside the
|
|
15
|
+
site, a scroll-edge shadow on code blocks wider than the viewport, and the on-page outline now
|
|
16
|
+
shows its own label instead of only an `aria-label`. See
|
|
17
|
+
[canopy's own changelog](https://github.com/iyulab/canopy/blob/main/CHANGELOG.md#0120--2026-08-22)
|
|
18
|
+
for details.
|
|
19
|
+
- **A `Ctrl K`/`⌘K` badge on the search box**, so the keyboard shortcut that already worked has
|
|
20
|
+
something telling a reader it exists. Hidden once the box has focus, and on narrow viewports
|
|
21
|
+
where the box collapses to an icon and a shortcut is unlikely to matter anyway.
|
|
22
|
+
- **`check` warns about a filename that needs percent-encoding in its own URL** — a stray space
|
|
23
|
+
or other ASCII character outside a URL's unreserved set, most often. The page still publishes
|
|
24
|
+
correctly (a static host serves the encoded URL fine), so this is a warning, not an error;
|
|
25
|
+
ignore it if the encoding is intended. Blind to non-ASCII on purpose: a Korean, Japanese, or
|
|
26
|
+
any other non-English filename needs encoding too, but that's the language, not a mistake.
|
|
27
|
+
|
|
10
28
|
## [0.12.0] — 2026-08-22
|
|
11
29
|
|
|
12
30
|
### Added
|
package/README.md
CHANGED
|
@@ -33,7 +33,8 @@ page never depends on any of the scripted ones: block scripts, or print the page
|
|
|
33
33
|
go away.
|
|
34
34
|
|
|
35
35
|
- **Search**, matching a query against every page's title, headings, and body — `Ctrl+K` /
|
|
36
|
-
`Cmd+K` jumps to it from anywhere
|
|
36
|
+
`Cmd+K` jumps to it from anywhere, badged on the search box itself so the shortcut is
|
|
37
|
+
discoverable without reading the docs
|
|
37
38
|
- **The current page and section, marked** in the sidebar and the on-page outline, updating as
|
|
38
39
|
you scroll
|
|
39
40
|
- **A dark/light toggle** that remembers a reader's choice; without one, pages follow the
|
|
@@ -45,9 +46,13 @@ go away.
|
|
|
45
46
|
- **Sidebar groups collapse**, open exactly along the path to the page you're on and closed
|
|
46
47
|
everywhere else
|
|
47
48
|
- **A breadcrumb trail** in the topbar, when there's a title, a logo, `home`, or search for it to
|
|
48
|
-
sit beside
|
|
49
|
+
sit beside — and an icon on `home` specifically when it points off the site, so a link sitting
|
|
50
|
+
right next to that trail doesn't look like it stays on it
|
|
49
51
|
- **A full-screen menu on narrow screens** that starts closed instead of opening on every page,
|
|
50
52
|
remembering a reader's own choice to leave it open for the rest of that visit
|
|
53
|
+
- **A code block wider than the screen shows a shadow at whichever edge still has more to
|
|
54
|
+
scroll to**, and nothing once you've scrolled there — a cue for a scrollbar that some
|
|
55
|
+
OS/browser combinations hide until hovered
|
|
51
56
|
- **Sitemap and `robots.txt`**, once `siteUrl` is set
|
|
52
57
|
|
|
53
58
|
See it live at <https://iyulab.github.io/canopy-page>, or read
|
|
@@ -236,6 +241,11 @@ Warnings — reported, and the build continues:
|
|
|
236
241
|
- A section with no `label` and no index page, whose sidebar heading falls back to its own
|
|
237
242
|
directory name — a filesystem detail, not a name anyone chose. Add a `label`, or an index page
|
|
238
243
|
for the section to name itself
|
|
244
|
+
- A filename whose published URL needs percent-encoding — a stray space or other ASCII
|
|
245
|
+
character outside a URL's unreserved set, most often. The page still publishes and works; this
|
|
246
|
+
is a nudge to check whether the encoding was intended, not a defect. Blind to non-ASCII on
|
|
247
|
+
purpose, so a Korean, Japanese, or any other non-English filename is never flagged for being
|
|
248
|
+
itself
|
|
239
249
|
|
|
240
250
|
Checking reads the settings and each page. It never renders, so it is fast enough to sit at the
|
|
241
251
|
front of a pipeline, at the scale a product manual reaches. References inside fenced
|
package/dist/assets/search.css
CHANGED
|
@@ -8,6 +8,44 @@
|
|
|
8
8
|
position: relative;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/* Reserve room so the shortcut badge below doesn't sit on top of typed
|
|
12
|
+
text — canopy's own input padding only accounts for its search icon on
|
|
13
|
+
the left. */
|
|
14
|
+
.canopy-search input[type="search"] {
|
|
15
|
+
padding-right: 3rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Advertises Ctrl+K/Cmd+K (search.js). An inert glyph, not a button — same
|
|
19
|
+
masked-icon-adjacent technique canopy's own shell uses for its search and
|
|
20
|
+
theme-toggle icons: pointer-events: none lets a click straight through to
|
|
21
|
+
the input underneath it. Hidden once the input has focus, so it doesn't
|
|
22
|
+
crowd a query being typed, and on narrow viewports, where canopy's own
|
|
23
|
+
shell (styles.ts, the `max-width: 40rem` breakpoint) collapses the input
|
|
24
|
+
to an icon-sized 2.25rem with no room for a badge — and where a physical
|
|
25
|
+
keyboard, the whole reason the shortcut exists, is unlikely anyway. */
|
|
26
|
+
.canopy-search-shortcut {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 50%;
|
|
29
|
+
right: var(--sp-2);
|
|
30
|
+
transform: translateY(-50%);
|
|
31
|
+
padding: 0.05em 0.4em;
|
|
32
|
+
border: 1px solid var(--border);
|
|
33
|
+
border-radius: var(--radius-m);
|
|
34
|
+
font-size: 0.75em;
|
|
35
|
+
line-height: 1.4;
|
|
36
|
+
color: var(--text-muted);
|
|
37
|
+
background: var(--bg-secondary);
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
}
|
|
40
|
+
.canopy-search input[type="search"]:focus ~ .canopy-search-shortcut {
|
|
41
|
+
display: none;
|
|
42
|
+
}
|
|
43
|
+
@media (max-width: 40rem) {
|
|
44
|
+
.canopy-search-shortcut {
|
|
45
|
+
display: none;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
11
49
|
.canopy-search-results {
|
|
12
50
|
position: absolute;
|
|
13
51
|
top: 100%;
|
package/dist/assets/search.js
CHANGED
|
@@ -208,6 +208,19 @@ var CanopySearch = (function () {
|
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
210
|
|
|
211
|
+
// The shortcut above only works if a reader knows it exists — the badge
|
|
212
|
+
// is what tells them. Built here rather than in canopy's own shell markup
|
|
213
|
+
// because only this script knows the shortcut actually ended up wired
|
|
214
|
+
// (a build with no --script attached never reaches this line at all, so
|
|
215
|
+
// it never advertises a key that would do nothing). CSS hides it once
|
|
216
|
+
// the input has focus (search.css) so it doesn't crowd a query being
|
|
217
|
+
// typed.
|
|
218
|
+
var shortcut = document.createElement("kbd");
|
|
219
|
+
shortcut.className = "canopy-search-shortcut";
|
|
220
|
+
shortcut.setAttribute("aria-hidden", "true");
|
|
221
|
+
shortcut.textContent = /Mac|iPhone|iPad/.test(navigator.platform || "") ? "⌘K" : "Ctrl K";
|
|
222
|
+
form.appendChild(shortcut);
|
|
223
|
+
|
|
211
224
|
// A script that ran this far is a script that can wire the form up —
|
|
212
225
|
// reveal it now, and not before, so a build with no script attached
|
|
213
226
|
// (or one that throws before this point) never shows a dead control.
|
package/dist/check.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { type Finding, type LoadedSite } from "./site.js";
|
|
2
|
+
/**
|
|
3
|
+
* A published path's segments, exactly where percent-encoding canopy applies
|
|
4
|
+
* to the *link* (never the file, which keeps its raw name) turns out to
|
|
5
|
+
* matter: `relativeHref` (canopy's site-path.ts) encodes each segment with
|
|
6
|
+
* `encodeURIComponent`, so a name with a space or other URL-unsafe character
|
|
7
|
+
* still resolves — a static host serves "error%20messages.html" correctly —
|
|
8
|
+
* but nothing tells the author whether that was intended. Pages become
|
|
9
|
+
* `.html`; every other published file's segments are checked exactly as
|
|
10
|
+
* written, mirroring `toSitePath`'s own "everything but markdown passes
|
|
11
|
+
* through unchanged".
|
|
12
|
+
*/
|
|
13
|
+
export declare function filenameEncodingFindings(site: LoadedSite): Finding[];
|
|
2
14
|
/** Check every page's references, returning one finding per broken reference. */
|
|
3
15
|
export declare function referenceFindings(site: LoadedSite): Promise<Finding[]>;
|
|
4
16
|
/**
|
package/dist/check.js
CHANGED
|
@@ -85,6 +85,57 @@ function wikilinkExists(site, target) {
|
|
|
85
85
|
return site.index.resolve(target) !== undefined;
|
|
86
86
|
return site.index.pages.some((page) => toPageKey(page).split("/").pop() === key);
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* `encodeURIComponent`'s unreserved set — the ASCII characters it leaves
|
|
90
|
+
* alone. Everything else ASCII (a space, `#`, `&`, `?`, …) is the kind of
|
|
91
|
+
* character that lands in a filename by accident — a stray space, a
|
|
92
|
+
* character copied from somewhere that meant it as punctuation, not a path.
|
|
93
|
+
*/
|
|
94
|
+
const ASCII_URI_SAFE = /^[A-Za-z0-9\-_.!~*'()]$/;
|
|
95
|
+
/**
|
|
96
|
+
* True if `segment` contains an ASCII character `encodeURIComponent` would
|
|
97
|
+
* escape. Deliberately blind to non-ASCII: canopy percent-encodes every
|
|
98
|
+
* character outside the unreserved set, which means *any* non-English
|
|
99
|
+
* filename — a Korean directory name, an emoji — would otherwise trip this,
|
|
100
|
+
* and canopy-page's own demo site intentionally ships one (see
|
|
101
|
+
* `examples/site/guide/한국어-예시/`) as a *supported* pattern, not a mistake
|
|
102
|
+
* to flag. An ASCII character in the escaped set, on the other hand, is
|
|
103
|
+
* consistently a slip — nobody names a file "error#messages.md" on purpose.
|
|
104
|
+
*/
|
|
105
|
+
function hasAsciiEncodingIssue(segment) {
|
|
106
|
+
for (const char of segment) {
|
|
107
|
+
const code = char.codePointAt(0);
|
|
108
|
+
if (code !== undefined && code <= 0x7f && !ASCII_URI_SAFE.test(char))
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A published path's segments, exactly where percent-encoding canopy applies
|
|
115
|
+
* to the *link* (never the file, which keeps its raw name) turns out to
|
|
116
|
+
* matter: `relativeHref` (canopy's site-path.ts) encodes each segment with
|
|
117
|
+
* `encodeURIComponent`, so a name with a space or other URL-unsafe character
|
|
118
|
+
* still resolves — a static host serves "error%20messages.html" correctly —
|
|
119
|
+
* but nothing tells the author whether that was intended. Pages become
|
|
120
|
+
* `.html`; every other published file's segments are checked exactly as
|
|
121
|
+
* written, mirroring `toSitePath`'s own "everything but markdown passes
|
|
122
|
+
* through unchanged".
|
|
123
|
+
*/
|
|
124
|
+
export function filenameEncodingFindings(site) {
|
|
125
|
+
const findings = [];
|
|
126
|
+
for (const file of [...site.index.pages, ...site.index.assets]) {
|
|
127
|
+
const published = file.replace(/\.md$/i, ".html");
|
|
128
|
+
const segments = published.split("/");
|
|
129
|
+
if (!segments.some(hasAsciiEncodingIssue))
|
|
130
|
+
continue;
|
|
131
|
+
const href = segments.map((segment) => encodeURIComponent(segment)).join("/");
|
|
132
|
+
findings.push({
|
|
133
|
+
level: "warning",
|
|
134
|
+
message: `${file}: published URL is "${href}" (rename to avoid the encoding, or ignore if intentional)`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return findings;
|
|
138
|
+
}
|
|
88
139
|
/** Check every page's references, returning one finding per broken reference. */
|
|
89
140
|
export async function referenceFindings(site) {
|
|
90
141
|
const findings = [];
|
|
@@ -169,6 +220,7 @@ export async function siteFindings(site) {
|
|
|
169
220
|
return [
|
|
170
221
|
...settingsFindings(site),
|
|
171
222
|
...navFindings(site.nav),
|
|
223
|
+
...filenameEncodingFindings(site),
|
|
172
224
|
...(await referenceFindings(site)),
|
|
173
225
|
];
|
|
174
226
|
}
|
package/dist/vault.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the source tree a settings file describes.
|
|
3
|
+
*
|
|
4
|
+
* canopy-page has to see the same files canopy will publish, because everything
|
|
5
|
+
* it does is about them: expanding `guide/*` into pages, reporting a link to a
|
|
6
|
+
* page that does not exist, deciding what a section contains. The checks are
|
|
7
|
+
* only worth anything if the file list they run against is the one that ships.
|
|
8
|
+
*
|
|
9
|
+
* That means the exclusion rules here have to agree with canopy's, and they are
|
|
10
|
+
* stated in canopy's README as the interface they are: dot-prefixed directories
|
|
11
|
+
* and `node_modules` are never published, and caller patterns come in three
|
|
12
|
+
* shapes. Agreeing by restating is a seam — if canopy ever widens its dialect,
|
|
13
|
+
* a check here would quietly disagree with the build. See
|
|
14
|
+
* TODO(upstream: claudedocs/issues/ISSUE-canopy-20260806-published-file-listing.md)
|
|
15
|
+
* for the proposal that would let a consumer ask canopy instead of restating it.
|
|
16
|
+
*/
|
|
17
|
+
/** Directories whose contents are never published, whatever the settings say. */
|
|
18
|
+
export declare function isSkippedDir(name: string): boolean;
|
|
1
19
|
/**
|
|
2
20
|
* Match a site-relative POSIX path against one exclusion pattern.
|
|
3
21
|
*
|
package/dist/vault.js
CHANGED
|
@@ -17,7 +17,7 @@ import path from "node:path";
|
|
|
17
17
|
* for the proposal that would let a consumer ask canopy instead of restating it.
|
|
18
18
|
*/
|
|
19
19
|
/** Directories whose contents are never published, whatever the settings say. */
|
|
20
|
-
function isSkippedDir(name) {
|
|
20
|
+
export function isSkippedDir(name) {
|
|
21
21
|
return name.startsWith(".") || name === "node_modules";
|
|
22
22
|
}
|
|
23
23
|
/**
|
package/dist/watch.js
CHANGED
|
@@ -3,6 +3,7 @@ import http from "node:http";
|
|
|
3
3
|
import { basename, extname, resolve, sep } from "node:path";
|
|
4
4
|
import { watch as watchFiles } from "chokidar";
|
|
5
5
|
import { buildSite } from "./build.js";
|
|
6
|
+
import { isSkippedDir } from "./vault.js";
|
|
6
7
|
/**
|
|
7
8
|
* Serving a build's output locally during authoring.
|
|
8
9
|
*
|
|
@@ -240,8 +241,7 @@ export async function watchSite(options) {
|
|
|
240
241
|
return false;
|
|
241
242
|
if (resolved === resolvedOut || resolved.startsWith(outWithSep))
|
|
242
243
|
return true;
|
|
243
|
-
|
|
244
|
-
return name === "node_modules" || name.startsWith(".");
|
|
244
|
+
return isSkippedDir(basename(resolved));
|
|
245
245
|
},
|
|
246
246
|
});
|
|
247
247
|
// chokidar.watch() returns before its initial directory scan finishes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/canopy-page",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Authoring pipeline for documentation sites: one settings file, integrity checks, and a build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"vitest": "^4.1.9"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@iyulab/canopy": "^0.
|
|
56
|
+
"@iyulab/canopy": "^0.12.0",
|
|
57
57
|
"chokidar": "^5.0.0"
|
|
58
58
|
}
|
|
59
59
|
}
|