wiki-formant 0.23.0 → 0.23.1
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/react.d.ts +7 -0
- package/dist/react.js +28 -2
- package/package.json +4 -2
package/dist/react.d.ts
CHANGED
|
@@ -423,6 +423,13 @@ export declare function RailShell({ children, prefix, label, className }: RailSh
|
|
|
423
423
|
* matched on the PATH ONLY, deliberately: `?edit=` and `?history=` are modes a
|
|
424
424
|
* page enters, not destinations a rail selects, and reading them would drag
|
|
425
425
|
* `useSearchParams` into a statically-rendered wiki.
|
|
426
|
+
*
|
|
427
|
+
* The path is decoded first. Next serves a catch-all route's prerender with the
|
|
428
|
+
* joined segments percent-encoded — `/wiki/tech%2Fcore-concepts` for
|
|
429
|
+
* `/wiki/tech/core-concepts` — so an encoded path matches neither its own href
|
|
430
|
+
* nor its section's prefix, and React does not patch a className on hydration.
|
|
431
|
+
* Both wikis were shipping every page below the top level with nothing in the
|
|
432
|
+
* rail marked, and it only came right if you arrived by client navigation.
|
|
426
433
|
*/
|
|
427
434
|
export declare function isRailLinkActive(activePath: string, href: string, tree?: boolean): boolean;
|
|
428
435
|
export type { WikiLinkComponent, WikiLinkProps } from './react-server.js';
|
package/dist/react.js
CHANGED
|
@@ -137,8 +137,15 @@ export function TableOfContents({ containerSelector, headings: providedHeadings,
|
|
|
137
137
|
// article per mutation is what makes a rail janky.
|
|
138
138
|
timer = setTimeout(() => {
|
|
139
139
|
const root = document.querySelector(containerSelector);
|
|
140
|
-
|
|
140
|
+
// No container is an answer, not a reason to skip: a rail that bailed
|
|
141
|
+
// here kept the LAST page's headings, so a section index reached from
|
|
142
|
+
// one of its own articles listed that article's sections under "on this
|
|
143
|
+
// page". It only looked right when a loading skeleton happened to render
|
|
144
|
+
// the container and scan to nothing.
|
|
145
|
+
if (!root) {
|
|
146
|
+
setScanned(prev => (prev.length ? [] : prev));
|
|
141
147
|
return;
|
|
148
|
+
}
|
|
142
149
|
const used = new Set();
|
|
143
150
|
const next = [];
|
|
144
151
|
for (const el of Array.from(root.querySelectorAll('h1, h2, h3'))) {
|
|
@@ -747,10 +754,29 @@ export function RailShell({ children, prefix, label, className }) {
|
|
|
747
754
|
* matched on the PATH ONLY, deliberately: `?edit=` and `?history=` are modes a
|
|
748
755
|
* page enters, not destinations a rail selects, and reading them would drag
|
|
749
756
|
* `useSearchParams` into a statically-rendered wiki.
|
|
757
|
+
*
|
|
758
|
+
* The path is decoded first. Next serves a catch-all route's prerender with the
|
|
759
|
+
* joined segments percent-encoded — `/wiki/tech%2Fcore-concepts` for
|
|
760
|
+
* `/wiki/tech/core-concepts` — so an encoded path matches neither its own href
|
|
761
|
+
* nor its section's prefix, and React does not patch a className on hydration.
|
|
762
|
+
* Both wikis were shipping every page below the top level with nothing in the
|
|
763
|
+
* rail marked, and it only came right if you arrived by client navigation.
|
|
750
764
|
*/
|
|
751
765
|
export function isRailLinkActive(activePath, href, tree = false) {
|
|
752
|
-
|
|
766
|
+
const path = decodePath(activePath);
|
|
767
|
+
return tree ? path === href || path.startsWith(`${href}/`) : path === href;
|
|
753
768
|
}
|
|
769
|
+
/** `decodeURIComponent` throws on a stray `%`; a path it cannot read is its own answer. */
|
|
770
|
+
const decodePath = (path) => {
|
|
771
|
+
if (!path.includes('%'))
|
|
772
|
+
return path;
|
|
773
|
+
try {
|
|
774
|
+
return decodeURIComponent(path);
|
|
775
|
+
}
|
|
776
|
+
catch {
|
|
777
|
+
return path;
|
|
778
|
+
}
|
|
779
|
+
};
|
|
754
780
|
// ---- rendered-article passes --------------------------------------------------
|
|
755
781
|
/**
|
|
756
782
|
* The `wiki-formant/dom` passes over a rendered article: tab groups, copy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-formant",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "The portable half of a wiki: derived taxonomy and facet controls, a version-negotiating MCP transport, markdown twins, block rendering, a rich-text editor engine, and conditional-GET plumbing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"markdown",
|
|
19
19
|
"agent"
|
|
20
20
|
],
|
|
21
|
-
"sideEffects": [
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"*.css"
|
|
23
|
+
],
|
|
22
24
|
"exports": {
|
|
23
25
|
".": {
|
|
24
26
|
"types": "./dist/index.d.ts",
|