fix: slightly cleaner solution to only showing files within the folder on folder pages

This commit is contained in:
Zen Visser 2025-01-17 20:42:36 +01:00 committed by GitHub
parent e34e1e0ff3
commit 647218866e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,7 +28,7 @@ export default ((opts?: Partial<FolderContentOptions>) => {
const FolderContent: QuartzComponent = (props: QuartzComponentProps) => { const FolderContent: QuartzComponent = (props: QuartzComponentProps) => {
const { tree, fileData, allFiles, cfg } = props const { tree, fileData, allFiles, cfg } = props
const folderSlug = stripSlashes(simplifySlug(fileData.slug!)) const folderSlug = simplifySlug(fileData.slug!)
const folderParts = folderSlug.split(path.posix.sep) const folderParts = folderSlug.split(path.posix.sep)
const allPagesInFolder: QuartzPluginData[] = [] const allPagesInFolder: QuartzPluginData[] = []
@ -36,7 +36,7 @@ export default ((opts?: Partial<FolderContentOptions>) => {
allFiles.forEach((file) => { allFiles.forEach((file) => {
const fileSlug = stripSlashes(simplifySlug(file.slug!)) const fileSlug = stripSlashes(simplifySlug(file.slug!))
const prefixed = fileSlug.startsWith(`${folderSlug}/`) && fileSlug !== folderSlug const prefixed = fileSlug.startsWith(folderSlug) && fileSlug !== folderSlug
const fileParts = fileSlug.split(path.posix.sep) const fileParts = fileSlug.split(path.posix.sep)
const isDirectChild = fileParts.length === folderParts.length + 1 const isDirectChild = fileParts.length === folderParts.length + 1