diff --git a/docs/make.d/phase0.jq b/docs/make.d/phase0.jq index 28d6523..23eb14a 100644 --- a/docs/make.d/phase0.jq +++ b/docs/make.d/phase0.jq @@ -1,15 +1,13 @@ -# phase0.jq --arg Version $(Version) --arg Metadata $(Metadata) -# -# Generate site.json from config.json. - -######################################################################## -# Output object -######################################################################## - -# Add some new members if not defined and delete `.defaults`. +# phase0.jq +# --arg Version $(Version) +# --arg Metadata $(Metadata) +# < $(Metadata)/config.json > $(Metadata)/site.json +# +# Delete `.defaults` and add some new members if not defined +# del(.defaults) -| . + { ++ { Destination: (.Destination // "_site"), Assets: (.Assets // "assets"), Blocks: (.Blocks // "blocks"), diff --git a/docs/make.d/phase1.jq b/docs/make.d/phase1.jq index bbda52b..ca25c46 100644 --- a/docs/make.d/phase1.jq +++ b/docs/make.d/phase1.jq @@ -1,17 +1,12 @@ -# phase1.jq +# phase1.jq < $(Metadata)/site.json > $(Metadata)/phase1.make # -# Generate phase1.make from site.json. -def comment: - "# vim:syntax=make" -; - -######################################################################## -# Output makefile -######################################################################## - -# Format members as make variables. +# Function to cheat vim +def comment: "# vim:syntax=make"; +# +# Format some members as make variables +# "__phase_1 := 1", "Assets := " + .Assets, "Blocks := " + .Blocks, diff --git a/docs/make.d/phase2.jq b/docs/make.d/phase2.jq index d5ccac6..c8a5c98 100644 --- a/docs/make.d/phase2.jq +++ b/docs/make.d/phase2.jq @@ -1,13 +1,18 @@ -# phase2.jq --arg ... -# -# Generate phase2.make from `find` output. +# find $(Content) MARKDOWN FILES | +# phase2.jq +# --arg DF "$$(find $(Data) -name '*.*')" +# --arg Content $(Content) +# --arg Data $(Data) +# --arg Destination $(Destination) +# --arg Metadata $(Metadata) +# > $(Metadata)/phase1.make -def comment: - "# vim:syntax=make" -; +def comment: "# vim:syntax=make"; def dir: - if test("/") then sub("/[^/]+$"; "/") else "./" end + if test("/") + then sub("/[^/]+$"; "/") + else "./" end ; def dpaths($paths): @@ -69,9 +74,9 @@ def data($files): else "DataCSV := " + ($DataCSV | map(d2m("csv")) | join(" ")) + "\n" end ; -######################################################################## +# # Output makefile -######################################################################## +# (.[:-1] / "\n") as $documents | [$documents[] | dir] | unique as $paths diff --git a/docs/make.d/phase21.jq b/docs/make.d/phase21.jq index 860a762..6802c20 100644 --- a/docs/make.d/phase21.jq +++ b/docs/make.d/phase21.jq @@ -1,6 +1,9 @@ -# phase21.jq - --arg Source s --arg Target s --arg Metadata s --slurpfile config s -# -# Generate each page.json files +# FRONT-MATTER | phase21.jq +# --arg Source s +# --arg Target s +# --arg Metadata s +# --slurpfile config s +# > $(Metadata)/pages/PAGE.json def basename: sub("\\.[^/]+$"; "") diff --git a/docs/make.d/phase3.jq b/docs/make.d/phase3.jq index 8c6d8b1..4944148 100644 --- a/docs/make.d/phase3.jq +++ b/docs/make.d/phase3.jq @@ -1,40 +1,51 @@ -# phase3.jq --arg Metadata $(Metadata) --arg Layouts $(Layouts) --arg Destination $(Destination) -# -# Generate phase3.make from pages.json +# phase3.jq +# --arg Metadata $(Metadata) +# --arg Layouts $(Layouts) +# --arg Destination $(Destination) +# < $(Metadata)/pages-by-id.json > $(Metadata)/phase3.make -def comment: - "# vim:syntax=make" -; +def comment: "# vim:syntax=make"; def use: if .use - then " "+(.use | join(" ")) + then " " + (.use | join(" ")) else "" end ; def flags: if .flags - then .flags | join(" ") + then " " + (.flags | join(" ")) else "" end ; +def layout: + " " + $Layouts + "/" + .layout + ".html" +; + def data: if .data - then .data | map("-m\(.):$(Metadata)/snippets.json") | join(" ") + then " " + (.data | map("-m\(.):$(Metadata)/snippets.json") | join(" ")) else "" end ; -######################################################################## + +def page: + " -mpage:" + $Metadata + "/pages/" + .id + ".json" +; + +# makefile rule for HTML page +def page_rule: + $Destination+"/"+.url+": " + .source + " " + layout + use, + "\t$(info ==> $@)", + "\t@$(JQT) -d $< " + data + flags + page + layout + " | $(DETAILS) > $@" +; + +# # Output makefile -######################################################################## +# "__phase_3 := 1", -(.[] | ( # for each page - $Destination+"/"+.url+": "+.source+" "+$Layouts+"/"+.layout+".html"+use, - "\t$(info ==> $@)", - "\t@$(JQT) "+data+" "+flags+" -mpage:"+$Metadata+"/pages/"+.id+".json -d $< "+$Layouts+"/"+.layout+".html | $(DETAILS) > $@" - ) -), +(.[] | page_rule), # for each page comment # vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=jq