Add trailing slash to paths
This commit is contained in:
parent
16808ee943
commit
8efbad5c63
1 changed files with 3 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ import { getCollection, type CollectionEntry } from "astro:content";
|
|||
export type Document = CollectionEntry<"docs">;
|
||||
|
||||
export function getDocumentPath(document: Document) {
|
||||
return "/" + document.id.replace(/\/_index$/, "");
|
||||
return "/" + document.id.replace(/\/_index$/, "") + "/";
|
||||
}
|
||||
|
||||
export function getDocumentTitle(document: Document) {
|
||||
|
|
@ -23,8 +23,8 @@ export async function getChildDocuments(parentDocument: Document | undefined) {
|
|||
const documents = await getCollection("docs");
|
||||
|
||||
const basePath =
|
||||
parentDocument !== undefined ? getDocumentPath(parentDocument) : "";
|
||||
const pathPattern = new RegExp(`^${basePath}/[^/]+$`);
|
||||
parentDocument !== undefined ? getDocumentPath(parentDocument) : "/";
|
||||
const pathPattern = new RegExp(`^${basePath}[^/]+/$`);
|
||||
|
||||
const childDocuments = documents.filter((document) => {
|
||||
const path = getDocumentPath(document);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue