@@ -398,7 +398,7 @@ local function setup()
398398 urlize = urlize,
399399
400400 chooseExistingFile = function(sitePathWithoutExt, exts)
401- local pathWithoutExt = sitePathToPath(sitePathWithoutExt)
401+ local pathWithoutExt = sitePathToPath(sitePathWithoutExt, 2 )
402402
403403 for _, ext in ipairs(exts) do
404404 local pathRel = pathWithoutExt.."."..ext
@@ -413,12 +413,12 @@ local function setup()
413413 end,
414414
415415 fileExists = function(sitePath)
416- local pathRel = sitePathToPath(sitePath)
416+ local pathRel = sitePathToPath(sitePath, 2 )
417417 return (isFile(DIR_CONTENT.."/"..pathRel))
418418 end,
419419
420420 fileExistsInOutput = function(sitePath, skipRewriting)
421- local pathRel = sitePathToPath(sitePath)
421+ local pathRel = sitePathToPath(sitePath, 2 )
422422 local pathOutputRel = skipRewriting and pathRel or rewriteOutputPath(pathRel)
423423 return (isFile(DIR_OUTPUT.."/"..pathOutputRel))
424424 end,
@@ -503,7 +503,7 @@ local function setup()
503503 thumbH, isLink = 0, thumbH
504504 end
505505
506- local pathImageRel = sitePathToPath(sitePathImageRel)
506+ local pathImageRel = sitePathToPath(sitePathImageRel, 2 )
507507 local thumbInfo = createThumbnail(pathImageRel, thumbW, thumbH, 2)
508508 local thumbUrl = toUrl("/"..thumbInfo.path)
509509
@@ -582,7 +582,7 @@ local function setup()
582582 onlyFilenames, filter = false, onlyFilenames
583583 end
584584
585- local pathRel = sitePathToPath(sitePath)
585+ local pathRel = sitePathToPath(sitePath, 2 )
586586 local dirPath = pathRel == "" and DIR_CONTENT or DIR_CONTENT.."/"..pathRel
587587 local sitePaths = {}
588588
@@ -625,7 +625,7 @@ local function setup()
625625 end,
626626
627627 getCompleteOutputPath = function(sitePath)
628- local pathRel = sitePathToPath(sitePath)
628+ local pathRel = sitePathToPath(sitePath, 2 )
629629 local pathOutputRel = rewriteOutputPath(pathRel)
630630 return DIR_OUTPUT.."/"..pathOutputRel
631631 end,
@@ -656,7 +656,7 @@ local function setup()
656656
657657 getImageDimensions = function(sitePath)
658658 local getImageDimensions_internal = getImageDimensions -- :BetterTraceback :BetterNameForRedirectedFunctionInErrorMessage
659- local wOrNil, hOrErr = getImageDimensions_internal(sitePathToPath(sitePath))
659+ local wOrNil, hOrErr = getImageDimensions_internal(sitePathToPath(sitePath, 2 ))
660660 return wOrNil, hOrErr
661661 end,
662662
@@ -907,7 +907,7 @@ local function setup()
907907 assertContext("config", "generateFromTemplate")
908908 !ARGS "sitePathRel,template:string ? paramsOrInit:table,function"
909909
910- local pathRel = sitePathToPath(sitePathRel)
910+ local pathRel = sitePathToPath(sitePathRel, 2 )
911911 local page = newPage(pathRel, false)
912912
913913 if type(paramsOrInit) == "table" then
@@ -928,14 +928,14 @@ local function setup()
928928 assertContext("config", "outputRaw")
929929 !ARGS "sitePathRel,contents:string"
930930
931- local pathRel = sitePathToPath(sitePathRel)
931+ local pathRel = sitePathToPath(sitePathRel, 2 )
932932 writeOutputFile("raw", pathRel, sitePathRel, contents, nil, "")
933933 end,
934934
935935 preserveRaw = function(sitePathRel)
936936 assertContext("config", "preserveRaw")
937937
938- local pathRel = sitePathToPath(sitePathRel)
938+ local pathRel = sitePathToPath(sitePathRel, 2 )
939939 local pathOutputRel = rewriteOutputPath(pathRel)
940940 local path = DIR_OUTPUT.."/"..pathOutputRel
941941
@@ -956,20 +956,25 @@ local function setup()
956956 return getContext().page.url.v:sub(1, #urlPrefix) == urlPrefix
957957 end,
958958
959- subpages = function(allowCurrentPage)
960- assertContext("template", "subpages")
959+ subpages = function(pathPrefixOrAllowCurrentPage)
960+ local subpages = {}
961+ local pageCurrent, pathPrefix, allowCurrentPage
961962
962- local pageCurrent = getContext().page
963- local dir = getDirectory(pageCurrent._path)
964- local subpages = {}
963+ if type(pathPrefixOrAllowCurrentPage) == "string" then
964+ pageCurrent = nil
965+ pathPrefix = sitePathToPath(pathPrefixOrAllowCurrentPage, 2)
966+ allowCurrentPage = false -- Doesn't matter.
967+ else
968+ assertContext("template", "subpages")
969+ pageCurrent = getContext().page
970+ pathPrefix = pageCurrent._path:gsub("[^/]+$", "")
971+ allowCurrentPage = pathPrefixOrAllowCurrentPage
972+ end
965973
966974 for _, page in ipairs(site._pages) do
967975 if (page ~= pageCurrent or allowCurrentPage) and (
968- dir == ""
969- or (
970- page._path:byte(#dir+1) == !(string.byte"/") and
971- page._path:find(dir, 1, true) == 1
972- )
976+ pathPrefix == ""
977+ or page._path:find(pathPrefix, 1, true) == 1
973978 ) then
974979 if not page._isGenerated then
975980 generateFromTemplateFile(page)
@@ -1204,7 +1209,7 @@ local function buildWebsite()
12041209 local function getT(kPath, default, kType, vType) -- Table
12051210 return get(
12061211 kPath, default, lineAssertTable, kType, vType,
1207- "config.%s must be a table of [%s]=%s.",
1212+ "config.lua: config. %s must be a table of [%s]=%s.",
12081213 kPath, (kType or "value"), (vType or "value")
12091214 )
12101215 end
0 commit comments