@limcpf/everything-is-a-markdown 0.6.5 → 0.6.6
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 +1 -1
- package/src/build.ts +5 -1
- package/src/runtime/app.js +32 -1
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -737,7 +737,11 @@ function pickHomeDoc(docs: DocRecord[]): DocRecord | null {
|
|
|
737
737
|
const inDefaultBranch = docs.filter((doc) => doc.branch == null || doc.branch === DEFAULT_BRANCH);
|
|
738
738
|
const candidates = inDefaultBranch.length > 0 ? inDefaultBranch : docs;
|
|
739
739
|
const byRoute = candidates.find((doc) => doc.route === "/index/");
|
|
740
|
-
|
|
740
|
+
if (byRoute) {
|
|
741
|
+
return byRoute;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
return [...candidates].sort(compareByRecentDateThenPath)[0] ?? null;
|
|
741
745
|
}
|
|
742
746
|
|
|
743
747
|
function buildPinnedMenuFolder(docs: DocRecord[], options: BuildOptions): FolderNode | null {
|
package/src/runtime/app.js
CHANGED
|
@@ -508,6 +508,37 @@ function isDocVisibleInBranch(doc, branch, defaultBranch) {
|
|
|
508
508
|
return docBranch === branch;
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
+
function parseDateToEpochMs(value) {
|
|
512
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const parsed = Date.parse(value);
|
|
517
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function getRecentSortEpochMs(doc) {
|
|
521
|
+
return parseDateToEpochMs(doc.updatedDate) ?? parseDateToEpochMs(doc.date);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function compareDocsByRecentDateThenRoute(left, right) {
|
|
525
|
+
const leftEpoch = getRecentSortEpochMs(left);
|
|
526
|
+
const rightEpoch = getRecentSortEpochMs(right);
|
|
527
|
+
|
|
528
|
+
if (leftEpoch != null && rightEpoch != null) {
|
|
529
|
+
const byDate = rightEpoch - leftEpoch;
|
|
530
|
+
if (byDate !== 0) {
|
|
531
|
+
return byDate;
|
|
532
|
+
}
|
|
533
|
+
} else if (leftEpoch != null && rightEpoch == null) {
|
|
534
|
+
return -1;
|
|
535
|
+
} else if (leftEpoch == null && rightEpoch != null) {
|
|
536
|
+
return 1;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return left.route.localeCompare(right.route, "ko-KR");
|
|
540
|
+
}
|
|
541
|
+
|
|
511
542
|
function cloneFilteredTree(nodes, visibleDocIds) {
|
|
512
543
|
const filteredNodes = [];
|
|
513
544
|
|
|
@@ -559,7 +590,7 @@ function pickHomeRoute(view) {
|
|
|
559
590
|
if (view.routeMap["/index/"]) {
|
|
560
591
|
return "/index/";
|
|
561
592
|
}
|
|
562
|
-
return view.docs[0]?.route || "/";
|
|
593
|
+
return [...view.docs].sort(compareDocsByRecentDateThenRoute)[0]?.route || "/";
|
|
563
594
|
}
|
|
564
595
|
|
|
565
596
|
function loadExpandedSet() {
|