{{ 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 />
            <center><h2>This is a Draft</h2></center>
            <hr />
        {{ end }}
    </p>

    {{ $layout_file := "headless-bundle-single.html" }}
    Layout file:
    <a href="{{ .Site.Params.source.url }}/tree/master/test/site/layouts/_default/{{ $layout_file }}">
        <code>{{ $layout_file }}</code>
    </a>

    {{ .Content }}
    <hr />

    {{ $headless := .Site.GetPage "page" "headless-page-bundle-x" }}

    <h2>Content from Headless Bundle Index page</h2>
    <h3>{{ $headless.Title }}</h3>
    {{ $headless.Content }}
    <h3 id="headless-bundle-params-debug">Headless Bundle Index Page Params (Debug)</h3>
    {{ partial "debugprint.html" $headless.Params }}

    {{ with $headless.Resources }}
        <h2>Content from Headless Bundle page Resources</h2>
        {{ range . }}
            <h3>{{ .Title }}</h3>
            {{ .Content }}
            <hr />
        {{ end }}

        <h3 id="headless-bundle-resource-debug">Headless Bundle Resources (Debug)</h3>
        {{ partial "debugprint.html" . }}
    {{ end }}

    <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 }}
    <h3 id="file-debug">File Object (Debug)</h3>
    {{ partial "debugprint.html" .File }}
</div>

{{ end }}
