{% set published = metatabs.meta.manualdate ? metatabs.meta.manualdate : metatabs.meta.modified %}

<main class="{{ item.elementType }} w-100 pb5 bl br bb">

	<div class="w-100 center grid-container">

		<aside class="grid-header ph3 pv3">

			<header>

				<div class="logo">
					<p class="pa0 ma0">
						<a class="link f1 fw9" href="{{ base_url }}" title="My Title">						
							{% if logo %}
								<img src="{{ base_url }}/{{ logo }}" class="logo-image"/>
							{% else %}
								{{ settings.title|e }}
							{% endif %}
						</a>
					</p>
				</div>
					
			</header>

			{% if widgets %}
				<div class="widgetcontainer">
				{% for index,widget in widgets %}
					<div id="{{ index }}" class="mt4-l mt3">
						{{ widget }}
					</div>
				{% endfor %}
				</div>
			{% endif %}

		</aside>

		<div class="grid-main ph3 ph4-l pv3 lh-copy f4-l f5 fw3">

			<nav id="breadcrumb">
				{% include 'partials/breadcrumb.twig' %}
			</nav>

			<article>
				<header>
				
					<h1>{{ title }}</h1>

					{% if ("top" in settings.themes.cyanine.datePosition or "top" in settings.themes.cyanine.authorPosition or "top" in settings.themes.cyanine.gitPosition or "top" in settings.themes.cyanine.printPosition) %}
					    <div class="f5 pv1 flex justify-between">
					        <div class="byline">
					            {% if "top" in settings.themes.cyanine.datePosition %}
					                <time pubdate datetime="{{ published }}" class="pr2">{{ settings.themes.cyanine.dateIntro }} {{ published|date(settings.themes.cyanine.dateFormat)  }}</time>
					            {% endif %}
					            {% if "top" in settings.themes.cyanine.authorPosition %}
					                <adress class="pr2">{{ settings.themes.cyanine.authorIntro }} {{ metatabs.meta.author|default(settings.author) }}</adress>
					            {% endif %}
					        </div>
					        <div class="funcicons">
					            {% if "top" in settings.themes.cyanine.gitPosition %}
					                <a class="link" title="edit on github" href="{{ settings.themes.cyanine.gitLink }}{{ item.path }}">{% if settings.themes.cyanine.editIcon %}<svg class="icon baseline icon-pencil"><use xlink:href="#icon-pencil"></use></svg>{% else %}{{ settings.themes.cyanine.editText }}{% endif %}</a>
					            {% endif %}
					            {% if "top" in settings.themes.cyanine.printPosition %}
					                <a class="link" title="open printer dialogue" href="#" onclick="if (window.print) {window.print();}">{% if settings.themes.cyanine.printIcon %}<svg class="icon baseline icon-printer"><use xlink:href="#icon-printer"></use></svg>{% else %}{{ settings.themes.cyanine.printText }}{% endif %}</a>
					            {% endif %}
					        </div>
					    </div>
					{% endif %}

				</header>

				{{ content }}

				{% if ("bottom" in settings.themes.cyanine.datePosition or "bottom" in settings.themes.cyanine.authorPosition or "bottom" in settings.themes.cyanine.gitPosition or "bottom" in settings.themes.cyanine.printPosition) %}
				    <div class="f5 pv1 flex justify-between">
				        <div class="byline">
				            {% if "bottom" in settings.themes.cyanine.datePosition %}
				                <time pubdate datetime="{{ published }}" class="pr2">{{ settings.themes.cyanine.dateIntro }} {{ published|date(settings.themes.cyanine.dateFormat)  }}</time>
				            {% endif %}
				            {% if "bottom" in settings.themes.cyanine.authorPosition %}
				                <adress class="pr2">{{ settings.themes.cyanine.authorIntro }} {{ metatabs.meta.author|default(settings.author) }}</adress>
				            {% endif %}
				        </div>
				        <div class="funcicons">
				            {% if "bottom" in settings.themes.cyanine.gitPosition %}
				                <a class="link" title="edit on github" href="{{ settings.themes.cyanine.gitLink }}{{ item.path }}">{% if settings.themes.cyanine.editIcon %}<svg class="icon baseline icon-pencil"><use xlink:href="#icon-pencil"></use></svg>{% else %}{{ settings.themes.cyanine.editText }}{% endif %}</a>
				            {% endif %}
				            {% if "bottom" in settings.themes.cyanine.printPosition %}
				                <a class="link" title="open printer dialogue" href="#" onclick="if (window.print) {window.print();}">{% if settings.themes.cyanine.printIcon %}<svg class="icon baseline icon-printer"><use xlink:href="#icon-printer"></use></svg>{% else %}{{ settings.themes.cyanine.printText }}{% endif %}</a>
				            {% endif %}
				        </div>
				    </div>
				{% endif %}

			</article>

			{% if item.elementType == 'file' %}

				{% if item.prevItem or item.nextItem %}

					<div id="bottompager" class="f5 pv5 flex-l flex-m justify-between {{ settings.themes.cyanine.fontnavi|default('tm-sans-serif') }}">
						{% if item.prevItem %}
							<a class="navigation link w-100 w-40-l w-40-m mv1 pv2 ph3 ba dim dib" href="{{ item.prevItem.urlRel }}">&lsaquo;&nbsp; {{ item.prevItem.name }}</a>
						{% endif %}
						{% if item.nextItem %}
							<a class="navigation link w-100 w-40-l w-40-m mv1 pv2 ph3 dib ba dim tr" href="{{ item.nextItem.urlRel }}">{{ item.nextItem.name }} &nbsp;&rsaquo;</a>
						{% endif %}
					</div>

				{% endif %}
			
			{% endif %}

			{% if item.elementType == 'folder' and metatabs.meta.glossary %}

				<nav class="f4-l f5">
					{% include 'partials/navigationGlossary.twig'  with {'glossary': item.folderContent} %}
				</nav>

			{% elseif item.elementType == 'folder' and item.contains == 'pages' %}

				{% if settings.themes.cyanine.nofoldernavi and (item.prevItem or item.nextItem) %}

					<div id="bottompager" class="f5 pv5 flex-l flex-m justify-between {{ settings.themes.cyanine.fontnavi|default('tm-sans-serif') }}">
						{% if item.prevItem %}
							<a class="navigation link w-100 w-40-l w-40-m mv1 pv2 ph3 ba dim dib" href="{{ item.prevItem.urlRel }}">&lsaquo;&nbsp; {{ item.prevItem.name }}</a>
						{% endif %}
						{% if item.nextItem %}
							<a class="navigation link w-100 w-40-l w-40-m mv1 pv2 ph3 dib ba dim tr" href="{{ item.nextItem.urlRel }}">{{ item.nextItem.name }} &nbsp;&rsaquo;</a>
						{% endif %}
					</div>

				{% else  %}
				
					<nav class="f4-l f5">
						{% include 'partials/navigationFlat.twig'  with {'flatnavi': item.folderContent} %}
					</nav>

				{% endif  %}

			{% elseif item.elementType == 'folder' and item.contains == 'posts' %}

				{% include 'partials/posts.twig' %}

			{% endif %}

		</div>

		<aside class="grid-sidebar ph3 pv3">

			<nav id="contentnav" class="contentnav{{ settings.themes.cyanine.collapseNav ? ' collapse' : '' }}" aria-label="Menu">

				<!-- burger menu controlled by invisible checkbox -->
	  			<input type="checkbox" id="burger" class="dn">
	  			<label for="burger" class="burgerbutton">&#9776;</label>	

	  			{% if multilang %}
	  				<div class="flex dib w-100 mb2">
		  				{% for lang,link in multilang %}
		  					<a class="pa2 mr1 ba link" href="{{ base_url }}{{ link }}">{{ lang }}</a>
		  				{% endfor %}
		  			</div>
	  			{% endif %}

				{% include 'partials/navigation.twig' %}

			</nav>

		</aside>

	</div>

</main>