Print draft pages

This commit is contained in:
Christoph Hagen 2022-08-31 09:02:40 +02:00
parent 1537aaab01
commit 4dc56e5dfe
3 changed files with 26 additions and 4 deletions

View File

@ -57,6 +57,11 @@ final class FileSystem {
*/
private var emptyPages: Set<String> = []
/**
All pages which have `status` set to ``PageState.draft``
*/
private var draftPages: Set<String> = []
/**
All paths to page element folders, indexed by their unique id.
@ -427,9 +432,23 @@ final class FileSystem {
guard !emptyPages.isEmpty else {
return
}
log.add(info: "\(emptyPages.count) empty pages:", source: "Files")
print("\(emptyPages.count) empty pages:")
for page in emptyPages.sorted() {
log.add(info: "\(page) has no content", source: "Files")
print(" " + page)
}
}
func isDraft(path: String) {
draftPages.insert(path)
}
func printDraftPages() {
guard !draftPages.isEmpty else {
return
}
print("\(draftPages.count) drafts:")
for page in draftPages.sorted() {
print(" " + page)
}
}

View File

@ -49,7 +49,9 @@ struct PageGenerator {
}
let url = files.urlInOutputFolder(path)
if pageContent == nil {
if page.state == .draft {
files.isDraft(path: page.path)
} else if pageContent == nil, page.state != .hidden {
files.isEmpty(page: path)
}
guard factory.page.generate(content, to: url) else {

View File

@ -22,9 +22,10 @@ do {
private let siteGenerator = try SiteGenerator()
try siteGenerator.generate(site: siteData)
print("Pages generated")
print("Pages generated\n")
files.createImages()
files.printEmptyPages()
files.printDraftPages()
print("Images generated")
files.copyRequiredFiles()
print("Required files copied")