Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the system filename separator more consistently. #7331

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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