extends layout

block content
	h1(class="h2") Blocks
	hr

	if (blocks)
		nav(aria-label="Page navigation")
			ul(class="pagination justify-content-center")
				li(class="page-item", class=(sort == "asc" ? "active" : false))
					a(class="page-link", href=(sort == "asc" ? "javascript:void(0)" : "/blocks?limit=" + limit + "&offset=0" + "&sort=asc"))
						span(aria-hidden="true") Oldest blocks first
				li(class="page-item", class=(sort == "desc" ? "active" : false))
					a(class="page-link", href=(sort == "desc" ? "javascript:void(0)" : "/blocks?limit=" + limit + "&offset=0" + "&sort=desc"))
						span(aria-hidden="true") Newest blocks first

		include includes/blocks-list.pug

		hr

		if (blockCount > limit)
			- var pageNumber = offset / limit + 1;
			- var pageCount = Math.floor(blockCount / limit);
			- if (pageCount * limit < blockCount) {
				- pageCount++;
			- }
			- var paginationUrlFunction = function(x) {
				- return paginationBaseUrl + "?limit=" + limit + "&offset=" + ((x - 1) * limit + "&sort=" + sort);
			- }
			
			hr

			include includes/pagination.pug
	else
		p No blocks found