Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/project/types/website/website-sidebar-auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
*/

import { basename, join, relative } from "path/mod.ts";
import { basename, join, relative, SEP, SEP_PATTERN } from "path/mod.ts";
import { kOrder } from "../../../config/constants.ts";
import { asNumber } from "../../../core/cast.ts";

Expand Down Expand Up @@ -127,8 +127,8 @@ async function sidebarItemsFromAuto(
// if this is an auto-dir that has an index page inside it
// then re-shuffle things a bit
if (isAutoDir) {
const root = nodeSet.root.split("/");
nodeSet.root = root.slice(0, -1).join("/");
const root = nodeSet.root.split(SEP_PATTERN);
nodeSet.root = root.slice(0, -1).join(SEP);
nodeSet.nodes = {
[root.slice(-1)[0]]: nodeSet.nodes,
};
Expand All @@ -137,7 +137,7 @@ async function sidebarItemsFromAuto(
entries.push(
...await nodesToEntries(
project,
`${nodeSet.root ? nodeSet.root + "/" : ""}`,
`${nodeSet.root ? nodeSet.root + SEP : ""}`,
nodeSet.nodes,
),
);
Expand Down Expand Up @@ -201,15 +201,15 @@ function autoSidebarNodes(
// split into directory heirarchy
let result: Record<string, SidebarNodes> = {};
inputs.forEach((p) =>
p.split("/").reduce(
p.split(SEP_PATTERN).reduce(
(o, k) => o[k] = o[k] || {},
result,
)
);

// index into the nodes based on the directory
if (directory) {
directory.split("/").forEach((p) => {
directory.split(SEP_PATTERN).forEach((p) => {
result = result[p];
});
}
Expand Down