Skip to content

Commit

Permalink
Some renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 10, 2017
1 parent ed49a91 commit 73c0e9f
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 26 deletions.
4 changes: 2 additions & 2 deletions bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ declare -A JSON_DATA_DOT=() YAML_DATA_DOT=()
# .page._content
# .page._highlight
# .page._id
# .page._path
# .page._source
# .page._toc

# < stdin > stdout
Expand All @@ -462,7 +462,7 @@ function merge
echo '(. / "<!--JQT-->") as [$body, $toc, $css] |'
# page
echo "{ $DOCUMENT_METADATA_NAME: ("; yaml2json < $front_matter
echo "+ { _id: \"$id\", _path: \"${DOCUMENT}\", "'_content: $body, _toc: $toc, _highlight: $css })}'
echo "+ { _id: \"$id\", _source: \"${DOCUMENT}\", "'_content: $body, _toc: $toc, _highlight: $css })}'
fi

# additional data
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks/menu-bar/markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
######################################################################>&
<ol class="menu-bar">
{% .site.menu[] %}
<li class='menu-bar__item {{if .path==$M.page._path then "menu-bar__item_current" else "" end}}'>
<li class='menu-bar__item {{if .source==$M.page._source then "menu-bar__item_current" else "" end}}'>
<a href="{{.URL}}">{{.name}}</a>
</li>
{% end %}
Expand Down
10 changes: 5 additions & 5 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ author:
# TODO: instrospect
menu:
- URL: ./index.html
path: content/index.md
source: content/index.md
name: Home
- URL: ./engine.html
path: content/engine.md
source: content/engine.md
name: Engine
- URL: ./structure.html
path: content/structure.md
source: content/structure.md
name: Structure
- URL: ./content.html
path: content/content.md
source: content/content.md
name: Content
- URL: ./data.html
path: content/data.md
source: content/data.md
name: Data

# Default values
Expand Down
1 change: 1 addition & 0 deletions docs/content/content.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
name: Content
layout: page-toc
title: Authoring content in jqt using MarkDown
description: jqt transforms MarkDown documents to HTML using Pandoc.
Expand Down
3 changes: 2 additions & 1 deletion docs/content/data.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
name: Data
layout: page-toc
title: Managing the data model with jqt
description: jqt combines one template with one MarkDown document and a data model.
Expand Down Expand Up @@ -59,7 +60,7 @@ are provided:

* `.page._content`: the rendered input document.
* `.page._highlight`: CSS styles for highlighted code.
* `.page._path`: the input document pathname as provided to `jqt`.
* `.page._source`: the input document pathname as provided to `jqt`.
* `.page._toc`: the rendered input document table of contents.

Additional JSON files can be provided and are merged with front matter metadata
Expand Down
1 change: 1 addition & 0 deletions docs/content/engine.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
name: Engine
layout: page-toc
title: The jqt template engine
description: jqt orchestrates several shell utilities to transform MarkDown text and YAML or JSON data into a final HTML page.
Expand Down
1 change: 1 addition & 0 deletions docs/content/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
name: Home
layout: page
title: Welcome to jqt
description: Could be jq the basis for a web template engine?
Expand Down
1 change: 1 addition & 0 deletions docs/content/structure.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
name: Structure
layout: page-toc
title: Defining the page structure with jqt
description: Web pages structure is defined by the HTML macros.
Expand Down
36 changes: 21 additions & 15 deletions docs/make.d/front-matter.make
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,24 @@ define f_page_section =
$(patsubst %/,%,$(call f_page_path,$1))
endef

# `.` is a MarkDown file front matter.
# Add members to user defined front-matter at `.`.
# Defined by jqt:
# .page._id
# .page._content
# .page._highlight
# .page._toc
# .page._source == $1
define f_PAGE_JSON.jq =
. + { \
source: "$1", \
id: "$(call f_page_id,$2)", \
base: "$(call f_page_base,$2)", \
filename: "$(call f_page_name,$2)", \
id: "$(call f_page_id,$2)", \
isnode: false, \
ispage: true, \
path: "$(call f_page_path,$2)", \
url: "$(call f_page_url,$2)", \
section: "$(call f_page_section,$2)", \
isnode: false, \
ispage: true \
source: "$1", \
url: "$(call f_page_url,$2)" \
} as $$page | \
$$config[0].defaults as $$defaults | \
reduce $$defaults[] as $$d \
Expand Down Expand Up @@ -96,17 +102,17 @@ endef

# `.` is `$(Metadata)/config.json`.
define f_NODE_JSON.jq =
{ id: "$(call f_node_id,$1)", \
{ \
base: "$(call f_page_base,$1)", \
title: "$(call f_page_name,$1)", \
filename: "$(call f_page_name,$1)", \
id: "$(call f_node_id,$1)", \
isnode: true, \
ispage: false, \
path: "$(call f_page_path,$1)", \
url: "$(call f_page_url,$1)", \
section: "$(call f_page_section,$1)", \
url: "$(call f_page_url,$1)", \
date: (now | todateiso8601), \
ishome: false, \
isnode: true, \
ispage: false \
title: "$(call f_page_name,$1)" \
} as $$node | \
reduce .defaults[] as $$d \
({}; if "$(call f_node_id,$1)" | test("^" + $$d.idprefix) \
Expand All @@ -125,14 +131,14 @@ $(NodesJSON): $(Metadata)/config.json

$(Metadata)/pages.json: $(PagesJSON)
$(info ==> $@)
@jq --slurp '{ pages: . }' $^ > $@
@jq --slurp '.' $^ > $@

$(Metadata)/sections.json: $(Metadata)/pages.json
$(info ==> $@)
@jq '{ sections: ([.pages[].section] | unique) }' < $< > $@
@jq '[.[].section] | unique' < $< > $@

$(Metadata)/nodes.json: $(NodesJSON)
$(info ==> $@)
@test -n "$^" && jq --slurp '{ nodes: . }' $^ > $@ || true
@test -n "$^" && jq --slurp '.' $^ > $@ || true

# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make
2 changes: 1 addition & 1 deletion docs/make.d/pages.make
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ endef

define p_PAGES_D_MAKE.jq :=
"__html__ := 1", \
(.pages[] | ( \
(.[] | ( \
"$(Destination)/"+.url+": "+(.use|join(" ")), \
"$(Destination)/"+.url+": $(Layouts)/default.html", \
"$(Destination)/"+.url+": $(Layouts)/"+.layout+".html", \
Expand Down
2 changes: 1 addition & 1 deletion docs/make.d/sitemap.make
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define s_sitemap.jq
<urlset xmlns:xsi='\''http://www.w3.org/2001/XMLSchema-instance'\'' \
xsi:schemaLocation='\''http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd'\'' \
xmlns='\''http://www.sitemaps.org/schemas/sitemap/0.9'\''>", \
( .pages[] | \
( .[] | \
"\t<url>", \
"\t\t<loc>" + $$baseurl + "/" + .url + "</loc>", \
"\t\t<lastmod>" + .updated + "</lastmod>", \
Expand Down

0 comments on commit 73c0e9f

Please sign in to comment.