mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-05-18 22:44:14 +02:00
fix: slightly cleaner solution to only showing files within the folder on folder pages
This commit is contained in:
parent
e34e1e0ff3
commit
647218866e
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user