Skip to content

Commit

Permalink
Graceful handling of sections without an index page an empty sections.
Browse files Browse the repository at this point in the history
Increase version for the bugfix.
  • Loading branch information
dmbaturin committed Jul 20, 2019
1 parent 7d79081 commit f1d3ae2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion soupault.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "2.0"
name: "soupault"
version: "1.0"
version: "1.0.1"
synopsis: "Static website generator based on HTML rewriting"
description: """
A templateless website generator that allows you to store metadata
Expand Down
2 changes: 1 addition & 1 deletion src/defaults.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ let default_settings = {
preprocessors = []
}

let version = "1.0"
let version = "1.0.1"
10 changes: 7 additions & 3 deletions src/soupault.ml
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@ let _process_page env index widgets config settings target_dir page_file =
when the section index is available *)
let reorder_pages settings ps =
let find_index = fun p -> (FP.basename p |> FP.chop_extension) = settings.index_page in
let index_page = List.find find_index ps in
let ps = CCList.remove ~eq:(=) ~key:index_page ps in
List.append ps [index_page]
let index_page = CCList.find_opt find_index ps in
match index_page with
| None -> ps
| Some p ->
let ps = CCList.remove ~eq:(=) ~key:p ps in
List.append ps [p]

(** If index file path is configured, add section index to the global index
that will be saved to the file *)
Expand All @@ -244,6 +247,7 @@ let rec process_dir env index widgets config settings base_src_dir base_dst_dir
let env = {env with nav_path = nav_path} in
let pages, assets = list_section_files settings src_path in
let pages = reorder_pages settings pages in
let () = FU.mkdir ~parent:true dst_path in
let dirs = List.map (FP.basename) (list_dirs src_path) in
let%m () = Utils.iter (_process_page env section_index widgets config settings dst_path) pages in
let%m () = Utils.cp assets dst_path in
Expand Down

0 comments on commit f1d3ae2

Please sign in to comment.