Skip to content

Commit

Permalink
Introspected menu
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Apr 11, 2017
1 parent 73c0e9f commit 9c45136
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 38 deletions.
14 changes: 5 additions & 9 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ include make.d/front-matter.make
# rules for all HTML files
# ======================================================================

ifdef __html__

# Options for `jqt`. To be extended in the site specific section.
JQTFLAGS = \
-I./ \
-msite:$(Metadata)/config.json \

endif

# ======================================================================
include make.d/pages.make
#
Expand Down Expand Up @@ -198,6 +189,11 @@ ifdef __html__

# Options for `jqt`.
JQTFLAGS += \
-n document \
-I./ \
-msite:$(Metadata)/config.json \
-mpages:$(Metadata)/pages.json \
-msections:$(Metadata)/sections.json \
-5 \
-iblocks/filters \
-msnippets:$(Metadata)/snippets.json \
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks/content/markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Content
######################################################################>&
<article class="$content">
{{.page._content}}
{{.document._content}}
</article>
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=html
Expand Down
4 changes: 2 additions & 2 deletions docs/blocks/default.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<# Top-level page markup #>&
<!DOCTYPE html>
<!-- this document uses polyglot markup (well formed XHTML5) -->
<html id="{{.page._id}}" xmlns="http://www.w3.org/1999/xhtml" lang="{{.page.lang//.site.lang}}" xml:lang="{{.page.lang//.site.lang}}">
<html id="{{.document._id}}" xmlns="http://www.w3.org/1999/xhtml" lang="{{.page.lang//.site.lang}}" xml:lang="{{.page.lang//.site.lang}}">
<head>
<#
# Meta elements
Expand All @@ -19,7 +19,7 @@
<link rel="shortcut icon" href="favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<link rel="stylesheet" type="text/css" href="styles.css"/>
{{.page._highlight}}
{{.document._highlight}}
</head>
<#
# Document body
Expand Down
6 changes: 4 additions & 2 deletions docs/blocks/menu-bar/markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
######################################################################>&
<ol class="menu-bar">
{% .site.menu[] %}
<li class='menu-bar__item {{if .source==$M.page._source then "menu-bar__item_current" else "" end}}'>
<a href="{{.URL}}">{{.name}}</a>
<li class='menu-bar__item {{if .==$M.page.id then "menu-bar__item_current" else "" end}}'>
{% (. as $id | $M.pages[] | select($id == .id)) as $page %}
<a href="{{$page.url}}">{{$page.name}}</a>
{% end %}
</li>
{% end %}
</ol>
Expand Down
2 changes: 1 addition & 1 deletion docs/blocks/toc/markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
######################################################################>&
<nav class="#panel -side-right toc">
<p class="toc__title">{{.snippets."toc-title"}}</p>
{{.page._toc}}
{{.document._toc}}
</nav>
<#
vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=html
Expand Down
26 changes: 7 additions & 19 deletions docs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,15 @@ baseURL: https://fadado.github.com/jqt/
lang: &lang en
logo: "❴❴❏❵❵"

author:
author: &author
- email: [email protected]
name: &author Joan Josep Ordinas Rosa

# TODO: instrospect
name: Joan Josep Ordinas Rosa
menu:
- URL: ./index.html
source: content/index.md
name: Home
- URL: ./engine.html
source: content/engine.md
name: Engine
- URL: ./structure.html
source: content/structure.md
name: Structure
- URL: ./content.html
source: content/content.md
name: Content
- URL: ./data.html
source: content/data.md
name: Data
- index
- engine
- structure
- content
- data

# Default values
defaults:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ and <%cite jqt> injects it into the render stage under the global JSON scalar
`.page._content`. If the document contains fenced code blocks specifying the language of
the code block, the related highlight CSS code will be in the scalar `.page._highlight`. Also, the
HTML table of contents is available in the scalar `.page._toc`, and the path to the document
file in the scalar `.page._path`.
file in the scalar `.page._source`.

### MarkDown snippets

Expand Down
17 changes: 16 additions & 1 deletion docs/make.d/front-matter.make
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# `$(Metadata)/pages/path/to/page.json` => `path/to/page`
define f_page_id =
$(subst $(Metadata)/pages/,,$(basename $1))
$(subst $(Metadata)/pages/,$(empty),$(basename $1))
endef

# `$(Metadata)/pages/path/to/page.json` => `(../)+`
Expand Down Expand Up @@ -48,12 +48,27 @@ $(patsubst %/,%,$(call f_page_path,$1))
endef

# Add members to user defined front-matter at `.`.
#
# Defined by jqt:
# .page._id
# .page._content
# .page._highlight
# .page._toc
# .page._source == $1
# Defined here:
# .page.base
# .page.filename
# .page.id
# .page.isnode
# .page.ispage
# .page.path
# .page.section
# .page.source
# .page.url
#
# Parameters:
# $1: $(Content)/%.md
# $2: $(Metadata)/pages/%.json
define f_PAGE_JSON.jq =
. + { \
base: "$(call f_page_base,$2)", \
Expand Down
5 changes: 3 additions & 2 deletions docs/make.d/pages.make
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ define p_DETAILS :=
-e 's/<\/summary><\/p>/<\/summary>/'
endef

# . is $(Metadata)/pages.json
# Complete command
define p_recipe :=
"\t$$(info ==> $$@)\n\t@$$(JQT) -d $$< $(Layouts)/"+.layout+".html | $$(p_DETAILS) > $$@"
"\t$$(info ==> $$@)\n\t@$$(JQT) -mpage:$(Metadata)/pages/"+.id+".json -d $$< $(Layouts)/"+.layout+".html | $$(p_DETAILS) > $$@"
endef

# . is $(Metadata)/pages.json
define p_PAGES_D_MAKE.jq :=
"__html__ := 1", \
(.[] | ( \
Expand Down

0 comments on commit 9c45136

Please sign in to comment.