{{ define "head" }}

{{ partial "mathjax.html" }}

<!-- Chroma Github theme CSS -->
<link rel="stylesheet" href="{{ "css/github_chroma.css" | relURL }}" type="text/css" />
{{ end }}

{{ define "main" }}

<div class="post">
    <h1 class="post-title">{{ .Title }}</h1>

    <!-- Taxonomy debug -->
    {{ $page := . }}
    {{ with .Site.Taxonomies }}
        {{ range $key,$_ := . }}
            {{ with $page.Param $key }}
                {{ $val := . }}
                <p>
                    {{ printf `<span style="font-variant: small-caps;">%s</span>:` $key | safeHTML }}
                    {{ with $.Site.GetPage "taxonomyTerm" $key }}
                        {{ $taxonomy_page := . }}
                        {{ range $val }}
                            <a href="{{ printf "%s%s" $taxonomy_page.Permalink (. | urlize) }}">{{ . }}</a>
                        {{ end }}
                    {{ end }}
                </p>
            {{ end }}
        {{ end }}
    {{ end }}

    <p>
        {{ if .Params.draft }}
            <hr />
            <div style="text-align: center;"><h2>This is a Draft</h2></div>
            <hr />
        {{ end }}
    </p>

    <hr />
    <h3>Description/Summary</h3>
    {{ with .Description }}
        {{ . | markdownify }}
    {{ else }}
        {{ partial "summary_minus_toc.html" . | safeHTML }}
    {{ end }}
    <hr />

    {{ partial "header_image.html" . }}

    <h3>Content</h3>
    {{ .Content }}

    {{ if (not ($.Param "disable_debug")) }}
        {{ with .Resources }}
            <hr />
            <h3 id="resources">Resources</h3>
            <ul>
	        {{ range . }}
	            {{ if .RelPermalink }}
	                <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
	            {{ else }}
	                <li>{{ .ResourceType | title }} (no link, only embedded in page)</li>
	            {{ end }}
	        {{ end }}
            </ul>
        {{ end }}

        {{ with .Resources.ByType "page" }}
            <hr />
            <h3 id="sub-pages">Bundled Sub-pages</h3>
            {{ range . }}
                <h4>{{ .Title }}</h4>
                {{ .Content }}
            {{ end }}
        {{ end }}

        <hr />
        <a id="debug"></a>
        <h3 id="page-debug">Page (Debug)</h3>
        {{ partial "debugprint.html" . }}
        <h3 id="page-params-debug">Page Params (Debug)</h3>
        {{ partial "debugprint.html" .Params }}
        {{ with .Resources }}
            <h3 id="resource-debug">Resources (Debug)</h3>
            {{ partial "debugprint.html" . }}
        {{ end }}
        <h3 id="file-debug">File Object (Debug)</h3>
        {{ partial "debugprint.html" .File }}
    {{ end }}
</div>

{{ end }}
