typerighter 0.7.0 → 0.8.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.
@@ -0,0 +1,373 @@
1
+ import { E as e, _ as t, v as n, w as r } from "./shared-BIdsxcZ2.js";
2
+ import { Fragment as i, computed as a, createApp as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, h as f, inject as p, markRaw as m, mergeProps as h, nextTick as g, openBlock as _, provide as v, reactive as ee, readonly as y, ref as b, renderList as x, renderSlot as S, shallowRef as C, toDisplayString as w, unref as T, watch as te, withKeys as E, withModifiers as D } from "vue";
3
+ //#region ../../node_modules/.pnpm/@lucide+vue@1.30.0_vue@3.5.40_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/utils/isEmptyString.mjs
4
+ var O = (e) => e === "", ne = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), k = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), re = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), ie = (e) => {
5
+ let t = re(e);
6
+ return t.charAt(0).toUpperCase() + t.slice(1);
7
+ }, A = {
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ width: 24,
10
+ height: 24,
11
+ viewBox: "0 0 24 24",
12
+ fill: "none",
13
+ stroke: "currentColor",
14
+ "stroke-width": 2,
15
+ "stroke-linecap": "round",
16
+ "stroke-linejoin": "round"
17
+ }, ae = /* @__PURE__ */ Symbol("lucide-icons");
18
+ function oe() {
19
+ return p(ae, {});
20
+ }
21
+ //#endregion
22
+ //#region ../../node_modules/.pnpm/@lucide+vue@1.30.0_vue@3.5.40_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/Icon.mjs
23
+ var se = ({ name: e, iconNode: t, "icon-node": n, absoluteStrokeWidth: r, "absolute-stroke-width": i, strokeWidth: o, "stroke-width": s, size: c, color: l, ...u }, { slots: d }) => {
24
+ let { size: p, color: m, strokeWidth: h = 2, absoluteStrokeWidth: g = !1, class: _ = "" } = oe(), v = a(() => {
25
+ let e = O(r) || O(i) || r === !0 || i === !0 || g === !0, t = o || s || h || A["stroke-width"];
26
+ return e ? Number(t) * 24 / Number(c ?? p ?? A.width) : t;
27
+ });
28
+ return f("svg", {
29
+ ...A,
30
+ ...u,
31
+ width: c ?? p ?? A.width,
32
+ height: c ?? p ?? A.height,
33
+ stroke: l ?? m ?? A.stroke,
34
+ "stroke-width": v.value,
35
+ class: ne("lucide", _, ...e ? [`lucide-${k(ie(e))}-icon`, `lucide-${k(e)}`] : ["lucide-icon"])
36
+ }, [...(t ?? n ?? []).map((e) => f(...e)), ...d.default ? [d.default()] : []]);
37
+ }, j = (e, t) => (n, { slots: r, attrs: i }) => f(se, {
38
+ ...i,
39
+ ...n,
40
+ iconNode: t,
41
+ name: e
42
+ }, r.default ? { default: r.default } : void 0), ce = j("corner-left-up", [["path", {
43
+ d: "M14 9 9 4 4 9",
44
+ key: "1af5af"
45
+ }], ["path", {
46
+ d: "M20 20h-7a4 4 0 0 1-4-4V4",
47
+ key: "1blwi3"
48
+ }]]), M = j("file", [["path", {
49
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
50
+ key: "1oefj6"
51
+ }], ["path", {
52
+ d: "M14 2v5a1 1 0 0 0 1 1h5",
53
+ key: "wfsgrz"
54
+ }]]), N = j("folder", [["path", {
55
+ d: "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",
56
+ key: "1kt360"
57
+ }]]), le = ["href"], ue = { key: 1 }, de = ["href"], fe = { class: "td-dir-name" }, pe = { class: "td-dir-count" }, me = { key: 2 }, he = ["href"], ge = { class: "td-dir-name" }, _e = /*@__PURE__*/ d({
58
+ __name: "TdDirectoryIndex",
59
+ setup(e) {
60
+ let r = B(), o = $(), { withBase: d } = Le(), f = a(() => {
61
+ let e = n(r.path), t = o.directoryListings[e];
62
+ return {
63
+ url: e,
64
+ subdirectories: t?.subdirectories ?? [],
65
+ items: t?.items ?? []
66
+ };
67
+ }), p = a(() => f.value.url === "/"), m = a(() => d(t(n(f.value.url))));
68
+ return (e, t) => (_(), c("div", null, [
69
+ p.value ? s("", !0) : (_(), c("a", {
70
+ key: 0,
71
+ href: m.value,
72
+ class: "td-dir-row"
73
+ }, [u(T(ce), {
74
+ size: 16,
75
+ class: "td-dir-icon"
76
+ }), t[0] ||= l("span", { class: "td-dir-parent" }, "..", -1)], 8, le)),
77
+ f.value.subdirectories.length > 0 ? (_(), c("div", ue, [(_(!0), c(i, null, x(f.value.subdirectories, (e) => (_(), c("a", {
78
+ key: e.url,
79
+ href: T(d)(e.url),
80
+ class: "td-dir-row"
81
+ }, [
82
+ u(T(N), {
83
+ size: 16,
84
+ class: "td-dir-icon"
85
+ }),
86
+ l("span", fe, w(e.name), 1),
87
+ l("span", pe, w(e.count), 1)
88
+ ], 8, de))), 128))])) : s("", !0),
89
+ f.value.items.length > 0 ? (_(), c("div", me, [(_(!0), c(i, null, x(f.value.items, (e) => (_(), c("a", {
90
+ key: e.url,
91
+ href: T(d)(e.url),
92
+ class: "td-dir-row"
93
+ }, [u(T(M), {
94
+ size: 16,
95
+ class: "td-dir-icon"
96
+ }), l("span", ge, w(e.name), 1)], 8, he))), 128))])) : s("", !0)
97
+ ]));
98
+ }
99
+ }), P = (e, t) => {
100
+ let n = e.__vccOpts || e;
101
+ for (let [e, r] of t) n[e] = r;
102
+ return n;
103
+ }, F = /*#__PURE__*/ P(_e, [["__scopeId", "data-v-d73874c1"]]), ve = [
104
+ "id",
105
+ "tabindex",
106
+ "aria-pressed",
107
+ "aria-label",
108
+ "onKeydown"
109
+ ], ye = { class: "td-flashcard-face td-flashcard-face-question" }, be = { class: "td-flashcard-label" }, xe = { class: "td-flashcard-body" }, Se = { class: "td-flashcard-face td-flashcard-face-key" }, Ce = { class: "td-flashcard-label" }, we = { class: "td-flashcard-body" }, Te = /*#__PURE__*/ P(/* @__PURE__ */ d({
110
+ inheritAttrs: !1,
111
+ __name: "TdFlashcard",
112
+ props: {
113
+ id: { default: () => void 0 },
114
+ revealed: {
115
+ type: Boolean,
116
+ default: !1
117
+ },
118
+ disabled: {
119
+ type: Boolean,
120
+ default: !1
121
+ },
122
+ questionLabel: { default: "Question" },
123
+ keyLabel: { default: "Answer" }
124
+ },
125
+ setup(e, { expose: t }) {
126
+ let n = b(e.revealed);
127
+ te(() => e.revealed, () => {
128
+ n.value = e.revealed;
129
+ });
130
+ function r() {
131
+ if (e.disabled) return n.value;
132
+ let t = n.value;
133
+ return n.value = !n.value, t;
134
+ }
135
+ function i() {
136
+ let e = n.value;
137
+ return n.value = !0, e;
138
+ }
139
+ function a() {
140
+ let e = n.value;
141
+ return n.value = !1, e;
142
+ }
143
+ return t({
144
+ flip: r,
145
+ showQuestion: a,
146
+ showKey: i,
147
+ state: y(n)
148
+ }), (t, i) => (_(), c("div", h(t.$attrs, {
149
+ id: e.id,
150
+ class: ["td-flashcard", {
151
+ "is-revealed": n.value,
152
+ "is-disabled": e.disabled
153
+ }],
154
+ role: "button",
155
+ tabindex: e.disabled ? -1 : 0,
156
+ "aria-pressed": n.value,
157
+ "aria-label": n.value ? e.keyLabel : e.questionLabel,
158
+ onClick: r,
159
+ onKeydown: [E(D(r, ["prevent"]), ["enter"]), E(D(r, ["prevent"]), ["space"])]
160
+ }), [l("div", ye, [l("p", be, w(e.questionLabel), 1), l("div", xe, [S(t.$slots, "default")])]), l("div", Se, [l("p", Ce, w(e.keyLabel), 1), l("div", we, [S(t.$slots, "key")])])], 16, ve));
161
+ }
162
+ }), [["__scopeId", "data-v-95dfbffd"]]), I = typeof window < "u", L = Symbol("typedown-router"), R = {
163
+ frontmatter: {},
164
+ headings: [],
165
+ title: "Not Found"
166
+ };
167
+ function Ee(t, n = {}) {
168
+ let r = e(n.basePath ?? "/"), i = ee({
169
+ path: "/",
170
+ hash: "",
171
+ query: "",
172
+ contentSfc: void 0,
173
+ data: R
174
+ }), a = {
175
+ route: i,
176
+ async go(e, t) {
177
+ e = H(e, r), await a.onBeforeRouteChange?.(e) !== !1 && ((!I || t?.initialLoad || De(e, r, t)) && await s(e), c(), await a.onAfterRouteChange?.(e));
178
+ }
179
+ }, o;
180
+ async function s(e) {
181
+ let r = new URL(e, "http://a.com"), a = o = r.pathname;
182
+ try {
183
+ let e = await t(a);
184
+ if (!e) throw Error(`Page not found: ${a}`);
185
+ if (o === a) {
186
+ o = void 0;
187
+ let { default: t, __pageData: n } = e;
188
+ i.path = a, i.contentSfc = m(t), i.data = m(n), c(r), I && g(() => {
189
+ z(r.hash);
190
+ });
191
+ }
192
+ } catch {
193
+ o === a && (o = void 0, i.path = a, i.contentSfc = n.fallbackComponent ? m(n.fallbackComponent) : void 0, i.data = R, c(r));
194
+ }
195
+ }
196
+ function c(e = I ? location : {
197
+ search: "",
198
+ hash: ""
199
+ }) {
200
+ i.query = e.search, i.hash = decodeURIComponent(e.hash);
201
+ }
202
+ return I && (history.state ?? history.replaceState({}, ""), window.addEventListener("click", (e) => {
203
+ if (e.defaultPrevented || !(e.target instanceof Element) || e.button !== 0 || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) return;
204
+ let t = e.target.closest("a");
205
+ if (!t || t.hasAttribute("download") || t.hasAttribute("target")) return;
206
+ let n = t.getAttribute("href");
207
+ if (n === null) return;
208
+ let { href: r, origin: i, pathname: o } = new URL(n, t.baseURI);
209
+ i === location.origin && !o.match(/\.\w+$/) && (e.preventDefault(), a.go(r));
210
+ }, { capture: !0 }), window.addEventListener("popstate", async (e) => {
211
+ if (e.state == null) return;
212
+ let t = H(location.href, r);
213
+ await s(t), c(), await a.onAfterRouteChange?.(t);
214
+ }), window.addEventListener("hashchange", (e) => {
215
+ e.preventDefault(), c();
216
+ })), a;
217
+ }
218
+ function z(e) {
219
+ if (!e) return;
220
+ let t;
221
+ try {
222
+ t = document.getElementById(decodeURIComponent(e).slice(1)) ?? void 0;
223
+ } catch {
224
+ return;
225
+ }
226
+ t?.scrollIntoView({ block: "start" });
227
+ }
228
+ function B() {
229
+ return V().route;
230
+ }
231
+ function V() {
232
+ let e = p(L);
233
+ if (!e) throw Error("useRouter() called outside of Typedown app");
234
+ return e;
235
+ }
236
+ function De(e, t, { replace: n = !1 } = {}) {
237
+ let r = H(location.href, t);
238
+ if (e === r) return z(new URL(e, "http://a.com").hash), !1;
239
+ n ? history.replaceState({}, "", e) : (history.replaceState({ scrollPosition: window.scrollY }, ""), history.pushState({}, "", e));
240
+ let i = new URL(e, location.origin), a = new URL(r, location.origin);
241
+ return i.pathname === a.pathname ? (z(i.hash), !1) : !0;
242
+ }
243
+ function H(e, t) {
244
+ let n = new URL(e, "http://a.com"), i = n.pathname.replace(/\.html$/, "");
245
+ return t && i.startsWith(t) && (i = i.slice(t.length) || "/"), n.pathname = r(i), n.pathname + n.search + n.hash;
246
+ }
247
+ //#endregion
248
+ //#region src/client/app/components/Content.ts
249
+ var U = d({
250
+ name: "TypedownContent",
251
+ setup() {
252
+ let e = B();
253
+ return () => e.contentSfc ? f(e.contentSfc) : void 0;
254
+ }
255
+ }), W = "td-theme";
256
+ function G(e) {
257
+ if (typeof document > "u") return;
258
+ let t = e === "system" ? K() : e;
259
+ document.documentElement.classList.toggle("dark", t === "dark");
260
+ }
261
+ function K() {
262
+ return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
263
+ }
264
+ var q = b("system"), J = b(K()), Y = !1;
265
+ function X() {
266
+ Oe();
267
+ let e = a(() => q.value === "system" ? J.value : q.value), t = a(() => e.value === "dark");
268
+ function n(e) {
269
+ q.value = e, G(e), typeof localStorage < "u" && localStorage.setItem(W, e);
270
+ }
271
+ function r() {
272
+ n(e.value === "light" ? "dark" : "light");
273
+ }
274
+ return {
275
+ theme: y(q),
276
+ effectiveTheme: e,
277
+ isDark: t,
278
+ setTheme: n,
279
+ toggle: r
280
+ };
281
+ }
282
+ function Oe() {
283
+ if (!Y) {
284
+ if (Y = !0, typeof localStorage < "u") {
285
+ let e = localStorage.getItem(W);
286
+ (e === "light" || e === "dark" || e === "system") && (q.value = e);
287
+ }
288
+ G(q.value), typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
289
+ J.value = K(), q.value === "system" && G("system");
290
+ });
291
+ }
292
+ }
293
+ //#endregion
294
+ //#region src/client/app/composables/useTdContent.ts
295
+ var Z = Symbol("td-content");
296
+ function ke(e) {
297
+ let t = X(), n = {
298
+ page: a(() => e.data),
299
+ frontmatter: a(() => e.data.frontmatter),
300
+ title: a(() => e.data.title),
301
+ isDark: a(() => t.isDark.value)
302
+ };
303
+ return v(Z, n), n;
304
+ }
305
+ function Ae() {
306
+ let e = p(Z);
307
+ if (e === void 0) throw Error("useTdContent() called without a parent provideTdContent()");
308
+ return e;
309
+ }
310
+ //#endregion
311
+ //#region src/client/app/index.ts
312
+ var Q = Symbol("typedown-site-config"), je = Symbol("typedown-site-data"), Me = Symbol("typedown-page-loader"), Ne = Symbol("typedown-search-index");
313
+ async function Pe(e, t, n = {}, r = {}) {
314
+ let i = {
315
+ title: n.title ?? "",
316
+ description: n.description ?? "",
317
+ basePath: n.basePath ?? "/",
318
+ repo: n.repo
319
+ }, a = {
320
+ contentTree: r.contentTree ?? {
321
+ rootItems: [],
322
+ children: []
323
+ },
324
+ schemas: r.schemas ?? {},
325
+ directoryListings: r.directoryListings ?? {}
326
+ }, s = Ee(e, { basePath: i.basePath }), c = o(d({
327
+ name: "TypedownApp",
328
+ setup() {
329
+ return ke(s.route), () => f(t);
330
+ }
331
+ }));
332
+ c.provide(L, s), c.provide(Q, i), c.provide(je, a), c.provide(Me, e);
333
+ let l = C(r.searchIndex);
334
+ return c.provide(Ne, l), c.component("TypedownContent", U), c.component("DirectoryIndex", F), c.component("Flashcard", Te), typeof window < "u" && await s.go(location.href, {
335
+ replace: !0,
336
+ initialLoad: !0
337
+ }), {
338
+ app: c,
339
+ router: s,
340
+ searchIndex: l
341
+ };
342
+ }
343
+ function Fe() {
344
+ return p(Me, void 0);
345
+ }
346
+ function Ie() {
347
+ return p(Ne, C(void 0));
348
+ }
349
+ function Le() {
350
+ let t = p(Q, {
351
+ title: "",
352
+ description: "",
353
+ basePath: "/"
354
+ }), n = e(t.basePath);
355
+ return {
356
+ ...t,
357
+ withBase(e) {
358
+ return n === "/" ? e : n + e;
359
+ }
360
+ };
361
+ }
362
+ function $() {
363
+ return p(je, {
364
+ contentTree: {
365
+ rootItems: [],
366
+ children: []
367
+ },
368
+ schemas: {},
369
+ directoryListings: {}
370
+ });
371
+ }
372
+ //#endregion
373
+ export { $ as a, U as c, F as d, P as f, j as h, Le as i, B as l, M as m, Fe as n, Ae as o, N as p, Ie as r, X as s, Pe as t, V as u };
@@ -700,6 +700,6 @@ var v = (e, t) => Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0, y
700
700
  let t = /* @__PURE__ */ new Map(), n = 0;
701
701
  for (let r of Object.keys(e)) t.set(parseInt(r, 10), e[r]), ++n % 1e3 == 0 && await F(0);
702
702
  return t;
703
- }, F = (e) => new Promise((t) => setTimeout(t, e)), I = /[\n\r\p{Z}\p{P}]+/u;
703
+ }, F = (e) => new Promise((t) => setTimeout(t, e)), I = /[\n\r\p{Z}\p{P}]+/u, L = "m15 10c-2.7614 0-5 2.2386-5 5v98c0 2.761 2.2386 5 5 5h178c2.761 0 5-2.239 5-5v-98c0-2.7614-2.239-5-5-5zm-15 5c0-8.28427 6.71573-15 15-15h178c8.284 0 15 6.71573 15 15v98c0 8.284-6.716 15-15 15h-178c-8.28427 0-15-6.716-15-15z", R = "M30 30h70v16h-27v52h-16v-52h-27z", z = "m155 98-30-33h20v-35h20v35h20z", B = "0 0 208 128", V = "#a0522d", H = `<svg fill='none' viewBox='${B}' xmlns='http://www.w3.org/2000/svg'><path clip-rule='evenodd' d='${L}' fill-rule='evenodd' fill='${V}'/><path d='${R}' fill='${V}'/><path d='${z}' fill='${V}'/></svg>`, U = `data:image/svg+xml,${encodeURIComponent(H)}`;
704
704
  //#endregion
705
- export { _ as t };
705
+ export { B as a, R as i, L as n, _ as o, U as r, z as t };
@@ -1,7 +1,5 @@
1
- import { o as e } from "./constants-DJbUAb1-.js";
2
- import { _ as t, a as n, b as r, g as i, i as a, x as o } from "./shared-CpPZZ8IH.js";
3
- import { o as s } from "./brand-BfamszbH.js";
4
- import { n as c, t as l } from "./vite-DnP-_NzR.js";
1
+ import { A as e, F as t, O as n, P as r, d as i, f as a, s as o } from "./shared-BIdsxcZ2.js";
2
+ import { a as s, n as c, t as l } from "./vite-CASZdq-i.js";
5
3
  import u from "node:path";
6
4
  import d from "picocolors";
7
5
  import { build as f, createServer as p } from "vite";
@@ -30,8 +28,8 @@ function _(e) {
30
28
  <head>
31
29
  <meta charset="UTF-8">
32
30
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
33
- <title>${s(e.title)}</title>
34
- <meta name="description" content="${s(e.description)}">
31
+ <title>${o(e.title)}</title>
32
+ <meta name="description" content="${o(e.description)}">
35
33
  ${t}
36
34
  ${n}
37
35
  </head>
@@ -76,18 +74,18 @@ function b(e) {
76
74
  //#endregion
77
75
  //#region src/node/build/index.ts
78
76
  var x = "typerighter/client/theme-default";
79
- async function S(e, n = {}) {
80
- let { root: r, logger: i } = e, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", d = u.join(o, ".client"), p = u.join(o, ".server");
77
+ async function S(t, n = {}) {
78
+ let { root: r, logger: a } = t, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", d = u.join(o, ".client"), p = u.join(o, ".server");
81
79
  await h.rm(o, {
82
80
  recursive: !0,
83
81
  force: !0
84
82
  });
85
- let m = await e.getTdContext(), [_, v, b, S] = await Promise.all([
83
+ let m = await t.getTdContext(), [_, v, b, S] = await Promise.all([
86
84
  m.getConfig(),
87
85
  m.listFiles(),
88
86
  m.listFilesGroupedBySchema(),
89
87
  m.listSchemas()
90
- ]), E = await Promise.all(S.map(async (e) => [e, (await m.getSchema(e)).properties])), D = Object.fromEntries(E), O = a(Object.values(b).flat()), k = JSON.stringify({
88
+ ]), E = await Promise.all(S.map(async (e) => [e, (await m.getSchema(e)).properties])), D = Object.fromEntries(E), O = i(Object.values(b).flat()), k = JSON.stringify({
91
89
  title: _.siteTitle,
92
90
  description: _.siteDescription
93
91
  }), A = JSON.stringify({ contentTree: O }), j = u.join(r, "node_modules", ".typerighter");
@@ -107,12 +105,12 @@ async function S(e, n = {}) {
107
105
  siteData: A
108
106
  }))]);
109
107
  try {
110
- let a = c({ context: e }), l = e.createViteLogger(), m = new y(i, "Building client bundle...");
108
+ let i = c({ context: t }), l = t.createViteLogger(), m = new y(a, "Building client bundle...");
111
109
  await f({
112
110
  ...n.viteConfig,
113
111
  root: r,
114
112
  base: s,
115
- plugins: a,
113
+ plugins: i,
116
114
  customLogger: l,
117
115
  logLevel: "silent",
118
116
  build: {
@@ -128,12 +126,12 @@ async function S(e, n = {}) {
128
126
  });
129
127
  let b = await h.readdir(u.join(d, "assets")).catch(() => []);
130
128
  m.done(`Client bundle (${b.length} chunks)`);
131
- let x = new y(i, "Building SSR bundle...");
129
+ let x = new y(a, "Building SSR bundle...");
132
130
  await f({
133
131
  ...n.viteConfig,
134
132
  root: r,
135
133
  base: s,
136
- plugins: a,
134
+ plugins: i,
137
135
  customLogger: l,
138
136
  logLevel: "silent",
139
137
  build: {
@@ -143,12 +141,12 @@ async function S(e, n = {}) {
143
141
  emptyOutDir: !0
144
142
  }
145
143
  }), x.done("SSR bundle");
146
- let S = v.map((e) => {
147
- let n = t(e);
144
+ let S = v.map((t) => {
145
+ let n = e(t);
148
146
  return n === "index" ? "/" : `/${n}`;
149
147
  });
150
148
  S.push("/"), T(O.children, "", S);
151
- let C = new y(i, "Pre-rendering pages...");
149
+ let C = new y(a, "Pre-rendering pages...");
152
150
  await g({
153
151
  ssrEntryPath: u.join(p, "ssr-entry.js"),
154
152
  clientOutDir: d,
@@ -175,24 +173,25 @@ async function S(e, n = {}) {
175
173
  })
176
174
  ]);
177
175
  }
178
- i.log(`\nBuild complete. Output: ${o}`);
176
+ a.log(`\nBuild complete. Output: ${o}`);
179
177
  }
180
178
  function C(e) {
181
- let t = `/${e.contentDir}/${o}`, i = JSON.parse(e.siteConfig), a = JSON.parse(e.siteData), s = n((a.contentTree ?? {
179
+ let n = `/${e.contentDir}/${t}`, i = JSON.parse(e.siteConfig), o = JSON.parse(e.siteData), s = a((o.contentTree ?? {
182
180
  rootItems: [],
183
181
  children: []
184
182
  }).children ?? [], i.title ?? ""), c = JSON.stringify({
185
- ...a,
183
+ ...o,
186
184
  directoryListings: s
187
185
  });
188
186
  return `
189
187
  import { createTypedownApp } from 'typerighter/client';
190
188
  import { TdDirectoryIndex } from 'typerighter/client/theme-default';
189
+ import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
191
190
  import { renderToString } from 'vue/server-renderer';
192
191
  import { h } from 'vue';
193
192
  import theme from '${e.layoutImport}';
194
193
 
195
- const pages = import.meta.glob('${t}', { eager: true });
194
+ const pages = import.meta.glob('${n}', { eager: true });
196
195
  const contentExts = ${JSON.stringify(r)};
197
196
  const siteData = ${c};
198
197
 
@@ -208,9 +207,9 @@ function loadPageModule(pagePath) {
208
207
  const page = findPage(base);
209
208
  if (page) return Promise.resolve(page);
210
209
 
211
- if (pagePath.endsWith('/index')) {
212
- const dirPath = pagePath.slice(0, -'/index'.length) || '/';
213
- const dir = siteData.directoryListings[dirPath] || siteData.directoryListings[dirPath + '/'];
210
+ if (isIndexUrl(pagePath)) {
211
+ const dirPath = getDirectoryFromPageUrl(pagePath);
212
+ const dir = siteData.directoryListings[dirPath];
214
213
  if (dir) return Promise.resolve({
215
214
  default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
216
215
  __pageData: { frontmatter: {}, headings: [], title: dir.title },
@@ -229,14 +228,14 @@ export async function render(url) {
229
228
  `;
230
229
  }
231
230
  async function w(e, t) {
232
- let n = (await h.readdir(e, {
231
+ let r = (await h.readdir(e, {
233
232
  recursive: !0,
234
233
  withFileTypes: !0
235
- })).filter((e) => e.isFile() && !i(e.name)).map(async (n) => {
234
+ })).filter((e) => e.isFile() && !n(e.name)).map(async (n) => {
236
235
  let r = u.join(n.parentPath, n.name), i = u.relative(e, r), a = u.join(t, i);
237
236
  return h.mkdir(u.dirname(a), { recursive: !0 }).then(() => h.copyFile(r, a));
238
237
  });
239
- await Promise.all(n);
238
+ await Promise.all(r);
240
239
  }
241
240
  function T(e, t, n) {
242
241
  for (let r of e) {
@@ -598,12 +597,12 @@ var U = class {
598
597
  }
599
598
  }, K = (e = "") => new G(e), q = d.bold(d.cyan("[typerighter]"));
600
599
  function J() {
601
- let t = K("typerighter");
600
+ let e = K("typerighter");
602
601
  process.on("uncaughtException", (e) => {
603
602
  Y("runtime", e);
604
603
  }), process.on("unhandledRejection", (e) => {
605
604
  Y("runtime", e instanceof Error ? e : Error(String(e)));
606
- }), t.command("[root]", "Start dev server").alias("dev").option("--port <port>", "Port to listen on").option("--host", "Expose to network").action(async (e, t) => {
605
+ }), e.command("[root]", "Start dev server").alias("dev").option("--port <port>", "Port to listen on").option("--host", "Expose to network").action(async (e, t) => {
607
606
  let n = await p({
608
607
  root: X(e),
609
608
  configFile: !1,
@@ -614,48 +613,48 @@ function J() {
614
613
  }
615
614
  });
616
615
  await n.listen(), n.printUrls();
617
- }), t.command("build [root]", "Build for production").option("--outDir <dir>", "Output directory", { default: "dist" }).option("--base <path>", "Base public path", { default: "/" }).action(async (t, n) => {
618
- let r = e(X(t));
616
+ }), e.command("build [root]", "Build for production").option("--outDir <dir>", "Output directory", { default: "dist" }).option("--base <path>", "Base public path", { default: "/" }).action(async (e, t) => {
617
+ let n = s(X(e));
619
618
  try {
620
- await S(r, {
621
- outDir: n.outDir,
622
- base: n.base
619
+ await S(n, {
620
+ outDir: t.outDir,
621
+ base: t.base
623
622
  });
624
623
  } finally {
625
- r.dispose();
624
+ n.dispose();
626
625
  }
627
- }), t.command("init [root]", "Scaffold a new project").action(async (e) => {
628
- let { initialize: t } = await import("./init-Bfnl0t1B.js");
626
+ }), e.command("init [root]", "Scaffold a new project").action(async (e) => {
627
+ let { initialize: t } = await import("./init-cYe8Z2-E.js");
629
628
  await t(X(e));
630
- }), t.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
629
+ }), e.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
631
630
  let { preview: n } = await import("vite");
632
631
  (await n({
633
632
  root: X(e),
634
633
  preview: { port: t.port }
635
634
  })).printUrls();
636
- }), t.command("check [root]", "Check vault for errors").option("--fix", "Auto-fix formatting issues").action(async (t, n) => {
637
- let r = e(X(t)), { logger: i } = r;
635
+ }), e.command("check [root]", "Check vault for errors").option("--fix", "Auto-fix formatting issues").action(async (e, t) => {
636
+ let n = s(X(e)), { logger: r } = n;
638
637
  try {
639
- i.start("Checking vault...");
640
- let e = await r.getTdContext(), t = await e.checkVault();
641
- for (let e of t.diagnostics) e.severity === "error" ? i.error(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`) : i.warn(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`);
642
- if (n.fix && 0 < t.warningCount) {
643
- let t = await e.getConfig(), n = await e.listFiles(), r = 0;
644
- for (let i of n) {
645
- let n = await e.formatFile(i);
638
+ r.start("Checking vault...");
639
+ let e = await n.getTdContext(), i = await e.checkVault();
640
+ for (let e of i.diagnostics) e.severity === "error" ? r.error(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`) : r.warn(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`);
641
+ if (t.fix && 0 < i.warningCount) {
642
+ let t = await e.getConfig(), n = await e.listFiles(), i = 0;
643
+ for (let r of n) {
644
+ let n = await e.formatFile(r);
646
645
  if (n.changed) {
647
- let e = u.resolve(t.contentDir, i);
648
- m.writeFileSync(e, n.content), r++;
646
+ let e = u.resolve(t.contentDir, r);
647
+ m.writeFileSync(e, n.content), i++;
649
648
  }
650
649
  }
651
- 0 < r && i.success(`Fixed ${r} file(s)`);
650
+ 0 < i && r.success(`Fixed ${i} file(s)`);
652
651
  }
653
- let a = `${t.fileCount} files checked, ${t.errorCount} error(s), ${t.warningCount} warning(s)`;
654
- 0 < t.errorCount ? (i.error(a), process.exit(1)) : i.success(a);
652
+ let a = `${i.fileCount} files checked, ${i.errorCount} error(s), ${i.warningCount} warning(s)`;
653
+ 0 < i.errorCount ? (r.error(a), process.exit(1)) : r.success(a);
655
654
  } finally {
656
- r.dispose();
655
+ n.dispose();
657
656
  }
658
- }), t.help(), t.version("0.7.0"), t.parse();
657
+ }), e.help(), e.version("0.8.0"), e.parse();
659
658
  }
660
659
  function Y(e, t) {
661
660
  let n = t instanceof Error ? t.message : String(t);
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "./cli-CDd4TNg1.js";
1
+ import { t as e } from "./cli-Doj0ofRb.js";
2
2
  export { e as cli };
@@ -1,8 +1,7 @@
1
1
  import { type App, type Component, type ShallowRef } from 'vue';
2
2
  import { type Router } from './router';
3
- import type { PageModule, ContentTree, SchemaDefinition, DirectoryListing } from '@/shared';
3
+ import { type PageModule, type ContentTree, type SchemaDefinition, type DirectoryListing } from '@/shared';
4
4
  export { useTdContent, } from './composables/useTdContent';
5
- export { useUrl, } from './composables/useUrl';
6
5
  export { useRouter, useRoute, } from './router';
7
6
  export { Content, } from './components/Content';
8
7
  export interface TypedownSiteConfig {
@@ -33,6 +32,16 @@ export declare function createTypedownApp(loadPageModule: (path: string) => Prom
33
32
  }>;
34
33
  export declare function usePageLoader(): PageLoader | undefined;
35
34
  export declare function useSearchIndex(): ShallowRef<string | undefined>;
36
- export declare function useSiteConfig(): TypedownSiteConfig;
35
+ export declare function useSiteConfig(): {
36
+ withBase(path: string): string;
37
+ /** Site title */
38
+ title: string;
39
+ /** Site description */
40
+ description: string;
41
+ /** URL base path (e.g. "/" or "/blog") */
42
+ basePath: string;
43
+ /** Repository URL */
44
+ repo?: string;
45
+ };
37
46
  export declare function useSiteData(): TypedownSiteData;
38
47
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,GAAG,EACR,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AASb,OAAO,EACuB,KAAK,MAAM,EACxC,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,YAAY,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,GACP,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,SAAS,EAAE,QAAQ,GACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,OAAO,GACR,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,kBAAkB;IACjC,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,WAAW,EAAE,WAAW,CAAC;IACzB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1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