| {% extends 'layout.html' %}
| {% import 'nodes/custom/blog/_macros.html' as blogmacros %}
| {% from '_macros/_navigation.html' import navigation_homepage, navigation_project %}

| {% set title = 'blog' %}

| {% block css %}
| {{ super() }}
| {% if project.url != 'blender-cloud' %}
link(href="{{ url_for('static_cloud', filename='assets/css/project-main.css') }}", rel="stylesheet")
| {% endif %}
| {% endblock %}

| {% block page_title %}Blog{% endblock%}

| {% block navigation_tabs %}
| {% if project.url == 'blender-cloud' %}
| {{ navigation_homepage(title) }}
| {% else %}
| {{ navigation_project(project, navigation_links, extension_sidebar_links, title) }}
| {% endif %}
| {% endblock navigation_tabs %}

| {% block body %}
| {{ blogmacros.render_blog_index(node, project, posts, can_create_blog_posts, api, more_posts_available, posts_meta, pages=pages) }}
| {% endblock %}

| {% block footer_scripts %}

include ../_scripts
script.
	hopToTop(); // Display jump to top button

	/* Expand images when their link points to a jpg/png/gif */
	/* TODO: De-duplicate code from view post */
	var page_overlay = document.getElementById('page-overlay');
	$('.item-content a img').on('click', function(e){
		e.preventDefault();

		var href = $(this).parent().attr('href');
		var src = $(this).attr('src');

		if (href.match("jpg$") || href.match("png$") || href.match("gif$")) {
			$(page_overlay)
						.addClass('active')
						.html('<img src="' + src + '"/>');
		} else {
			window.location.href = href;
		}
	});

| {% endblock %}
