@ascribed/astro 0.3.3-next.25 → 0.4.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ascribed/astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The Astro integration for Ascribe.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"node": ">=24"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@ascribed/cli": "0.
|
|
62
|
-
"@ascribed/elements": "0.
|
|
63
|
-
"@ascribed/review": "0.
|
|
61
|
+
"@ascribed/cli": "0.4.0",
|
|
62
|
+
"@ascribed/elements": "0.4.0",
|
|
63
|
+
"@ascribed/review": "0.4.0",
|
|
64
64
|
"github-slugger": "^2.0.0",
|
|
65
65
|
"property-information": "^7.2.0",
|
|
66
66
|
"smol-toml": "^1.9.1"
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
"publishConfig": {
|
|
97
97
|
"access": "public"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "b91427ec3d086d6d3ca7da3be89dccb8ef92dd17",
|
|
100
99
|
"scripts": {
|
|
101
100
|
"build": "tsc -p tsconfig.build.json",
|
|
102
101
|
"typecheck": "tsc --noEmit",
|
|
@@ -9,7 +9,13 @@ import Head from "@ascribed/astro/Head.astro";
|
|
|
9
9
|
// what it is and where the current one is.
|
|
10
10
|
import Versions from "@ascribed/astro/Versions.astro";
|
|
11
11
|
import VersionBanner from "@ascribed/astro/VersionBanner.astro";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
neighbors,
|
|
14
|
+
sidebar,
|
|
15
|
+
type Formatted,
|
|
16
|
+
type SidebarGroup,
|
|
17
|
+
type SidebarPage,
|
|
18
|
+
} from "@ascribed/astro/content";
|
|
13
19
|
|
|
14
20
|
interface Props {
|
|
15
21
|
entry: CollectionEntry<"docs">;
|
|
@@ -40,12 +46,40 @@ const labelHtml = (of: { label: string; formatted?: Formatted }) =>
|
|
|
40
46
|
of.formatted?.label ?? escape(of.label);
|
|
41
47
|
const { available } = page(entry);
|
|
42
48
|
// The sidebar: the project's navigation, in ascribe.nav's order or the
|
|
43
|
-
// default one, each page with its address and label
|
|
49
|
+
// default one, each page with its address and label, and a nested section's
|
|
50
|
+
// pages right after its own page, each with its depth. With a versioned build,
|
|
44
51
|
// it shows the pages of the line this page is in. Previous and next are the
|
|
45
52
|
// pages before and after this one in the navigation's reading order.
|
|
46
53
|
const entries = await getCollection("docs");
|
|
47
54
|
const groups = sidebar(entries, { entry });
|
|
48
55
|
const { previous, next } = neighbors(entry, entries);
|
|
56
|
+
|
|
57
|
+
/** A sidebar page, with how many sections deep it is: 0 in a top section. */
|
|
58
|
+
interface Item {
|
|
59
|
+
page: SidebarPage<CollectionEntry<"docs">>;
|
|
60
|
+
depth: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A group's pages in order, each nested section's right after its own page,
|
|
65
|
+
* or after the group's pages when its own page is its `index.md`.
|
|
66
|
+
*/
|
|
67
|
+
function items(group: SidebarGroup<CollectionEntry<"docs">>, depth = 0): Item[] {
|
|
68
|
+
const placed = new Set<SidebarGroup<CollectionEntry<"docs">>>();
|
|
69
|
+
const out: Item[] = [];
|
|
70
|
+
for (const page of group.pages) {
|
|
71
|
+
out.push({ page, depth });
|
|
72
|
+
for (const section of group.sections) {
|
|
73
|
+
if (section.page?.entry !== page.entry) continue;
|
|
74
|
+
placed.add(section);
|
|
75
|
+
out.push(...items(section, depth + 1));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const section of group.sections) {
|
|
79
|
+
if (!placed.has(section)) out.push(...items(section, depth + 1));
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
49
83
|
---
|
|
50
84
|
|
|
51
85
|
<!doctype html>
|
|
@@ -63,8 +97,8 @@ const { previous, next } = neighbors(entry, entries);
|
|
|
63
97
|
<section>
|
|
64
98
|
<h2 set:html={labelHtml(group)} />
|
|
65
99
|
<ul>
|
|
66
|
-
{group.
|
|
67
|
-
<li>
|
|
100
|
+
{items(group).map(({ page: item, depth }) => (
|
|
101
|
+
<li data-depth={depth}>
|
|
68
102
|
<a
|
|
69
103
|
href={item.href}
|
|
70
104
|
aria-current={item.entry.id === entry.id ? "page" : undefined}
|