@quartz-community/folder-page 1.0.0 → 1.0.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/CHANGELOG.md +6 -0
- package/dist/components/index.js +29 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +32 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e7de665: A note with a frontmatter `permalink` (published at its permalink, Quartz 5.1+) stays in its folder in the folder listings, as in Obsidian Publish: pages are placed by their file path and linked by their address.
|
|
8
|
+
|
|
3
9
|
## 1.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
package/dist/components/index.js
CHANGED
|
@@ -293,6 +293,22 @@ function simplifySlug(fp) {
|
|
|
293
293
|
const res = stripSlashes(trimSuffix(fp, "index"), true);
|
|
294
294
|
return res.length === 0 ? "/" : res;
|
|
295
295
|
}
|
|
296
|
+
function slugifyFilePath(fp, excludeExt) {
|
|
297
|
+
fp = stripSlashes(fp);
|
|
298
|
+
const ext = getFileExtension(fp);
|
|
299
|
+
const withoutFileExt = fp.replace(new RegExp(ext + "$"), "");
|
|
300
|
+
const finalExt = [".md", ".html", void 0].includes(ext) ? "" : ext;
|
|
301
|
+
let slug2 = _sluggify(withoutFileExt);
|
|
302
|
+
if (endsWith(slug2, "_index")) {
|
|
303
|
+
slug2 = slug2.replace(/_index$/, "index");
|
|
304
|
+
}
|
|
305
|
+
const segments = slug2.split("/");
|
|
306
|
+
if (segments.length >= 2 && segments[segments.length - 1] === segments[segments.length - 2]) {
|
|
307
|
+
segments[segments.length - 1] = "index";
|
|
308
|
+
slug2 = segments.join("/");
|
|
309
|
+
}
|
|
310
|
+
return slug2 + (finalExt ?? "");
|
|
311
|
+
}
|
|
296
312
|
function joinSegments(...args) {
|
|
297
313
|
if (args.length === 0) {
|
|
298
314
|
return "";
|
|
@@ -326,6 +342,9 @@ function stripSlashes(s2, onlyStripPrefix) {
|
|
|
326
342
|
}
|
|
327
343
|
return s2;
|
|
328
344
|
}
|
|
345
|
+
function getFileExtension(s2) {
|
|
346
|
+
return s2.match(/\.[A-Za-z0-9]+$/)?.[0];
|
|
347
|
+
}
|
|
329
348
|
function isFolderPath(fplike) {
|
|
330
349
|
return fplike.endsWith("/") || endsWith(fplike, "index") || endsWith(fplike, "index.md") || endsWith(fplike, "index.html");
|
|
331
350
|
}
|
|
@@ -340,6 +359,14 @@ function resolveRelative(current, target) {
|
|
|
340
359
|
const res = joinSegments(pathToRoot(current), simplifySlug(target));
|
|
341
360
|
return res;
|
|
342
361
|
}
|
|
362
|
+
function slugifyPath(s2) {
|
|
363
|
+
return s2.split("/").map(
|
|
364
|
+
(segment) => segment.replace(/\s/g, "-").replace(/&/g, "-and-").replace(/%/g, "-percent").replace(/\?/g, "").replace(/#/g, "").replace(/[<>:"|*]/g, "").toLowerCase()
|
|
365
|
+
).join("/").replace(/\/$/, "");
|
|
366
|
+
}
|
|
367
|
+
function _sluggify(s2) {
|
|
368
|
+
return slugifyPath(s2);
|
|
369
|
+
}
|
|
343
370
|
|
|
344
371
|
// node_modules/preact/dist/preact.mjs
|
|
345
372
|
var n;
|
|
@@ -2737,7 +2764,8 @@ function pagesFromAllFiles(allFiles, folderSlug, showSubfolders) {
|
|
|
2737
2764
|
const subfolderFiles = /* @__PURE__ */ new Map();
|
|
2738
2765
|
for (const file of allFiles) {
|
|
2739
2766
|
if (file.unlisted === true) continue;
|
|
2740
|
-
const
|
|
2767
|
+
const rel = file.relativePath;
|
|
2768
|
+
const fileSlug = rel ? slugifyFilePath(rel) : file.slug;
|
|
2741
2769
|
if (!fileSlug || !fileSlug.startsWith(folderPrefix)) continue;
|
|
2742
2770
|
const relativePath = fileSlug.slice(folderPrefix.length);
|
|
2743
2771
|
if (!relativePath || relativePath === "index") continue;
|