Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moving exact file name determination into HTMLFileMode #146

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
making file location more accessible
Vithanco committed May 13, 2023
commit d316d32588f708e9dcdf8ec58b041192776a86a4
15 changes: 15 additions & 0 deletions Sources/Publish/API/HTMLFileMode.swift
Original file line number Diff line number Diff line change
@@ -15,3 +15,18 @@ public enum HTMLFileMode {
/// `section/item` becomes `section/item/index.html`.
case foldersAndIndexFiles
}


extension HTMLFileMode {

///Determining the right file name based on HTMLFileMode
public func filePath(for location: Location) -> Path {
switch self {
case .foldersAndIndexFiles:
return "\(location.path)/index.html"
case .standAloneFiles:
return "\(location.path).html"
}
}

}
7 changes: 1 addition & 6 deletions Sources/Publish/Internal/HTMLGenerator.swift
Original file line number Diff line number Diff line change
@@ -141,11 +141,6 @@ private extension HTMLGenerator {
}

func filePath(for location: Location, fileMode: HTMLFileMode) -> Path {
switch fileMode {
case .foldersAndIndexFiles:
return "\(location.path)/index.html"
case .standAloneFiles:
return "\(location.path).html"
}
return fileMode.filePath(for: location)
}
}