@kenjura/ursa 0.34.0 → 0.35.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 CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.35.0
2
+ 2025-12-11
3
+
4
+ - Fixed issue where directory indices were empty
5
+
1
6
  # 0.34.0
2
7
  2025-12-11
3
8
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@kenjura/ursa",
3
3
  "author": "Andrew London <andrew@kenjura.com>",
4
4
  "type": "module",
5
- "version": "0.34.0",
5
+ "version": "0.35.0",
6
6
  "description": "static site generator from MD/wikitext/YML",
7
7
  "main": "lib/index.js",
8
8
  "bin": {
@@ -200,17 +200,42 @@ export async function generate({
200
200
  allSourceFilenamesThatAreArticles.map(async (file) => {
201
201
  try {
202
202
  const rawBody = await readFile(file, "utf8");
203
+ const type = parse(file).ext;
204
+ const ext = extname(file);
205
+ const base = basename(file, ext);
206
+ const dir = addTrailingSlash(dirname(file)).replace(source, "");
207
+
208
+ // Calculate output paths for this file
209
+ const outputFilename = file
210
+ .replace(source, output)
211
+ .replace(parse(file).ext, ".html");
212
+ const url = '/' + outputFilename.replace(output, '');
203
213
 
204
214
  // Skip files that haven't changed (unless --clean flag is set)
205
215
  if (!_clean && !needsRegeneration(file, rawBody, hashCache)) {
206
216
  skippedCount++;
207
- return; // Skip this file
217
+ // Still need to populate jsonCache for directory indices
218
+ const meta = extractMetadata(rawBody);
219
+ const body = renderFile({
220
+ fileContents: rawBody,
221
+ type,
222
+ dirname: dir,
223
+ basename: base,
224
+ });
225
+ jsonCache.set(file, {
226
+ name: base,
227
+ url,
228
+ contents: rawBody,
229
+ bodyHtml: body,
230
+ metadata: meta,
231
+ transformedMetadata: '',
232
+ });
233
+ return; // Skip regenerating this file
208
234
  }
209
235
 
210
236
  console.log(`processing article ${file}`);
211
237
  regeneratedCount++;
212
238
 
213
- const type = parse(file).ext;
214
239
  const meta = extractMetadata(rawBody);
215
240
  const rawMeta = extractRawMetadata(rawBody);
216
241
  const bodyLessMeta = rawMeta ? rawBody.replace(rawMeta, "") : rawBody;
@@ -218,9 +243,6 @@ export async function generate({
218
243
  dirname(file),
219
244
  meta
220
245
  );
221
- const ext = extname(file);
222
- const base = basename(file, ext);
223
- const dir = addTrailingSlash(dirname(file)).replace(source, "");
224
246
 
225
247
  // Calculate the document's URL path (e.g., "/character/index.html")
226
248
  const docUrlPath = '/' + dir + base + '.html';
@@ -269,10 +291,6 @@ export async function generate({
269
291
  // Pass docUrlPath so relative links can be resolved correctly
270
292
  finalHtml = markInactiveLinks(finalHtml, validPaths, docUrlPath, false);
271
293
 
272
- const outputFilename = file
273
- .replace(source, output)
274
- .replace(parse(file).ext, ".html");
275
-
276
294
  console.log(`writing article to ${outputFilename}`);
277
295
 
278
296
  await outputFile(outputFilename, finalHtml);
@@ -280,7 +298,6 @@ export async function generate({
280
298
  // json
281
299
 
282
300
  const jsonOutputFilename = outputFilename.replace(".html", ".json");
283
- const url = '/' + outputFilename.replace(output, '');
284
301
  const jsonObject = {
285
302
  name: base,
286
303
  url,