diff options
Diffstat (limited to 'layouts/blog_article.html')
| -rw-r--r-- | layouts/blog_article.html | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/layouts/blog_article.html b/layouts/blog_article.html new file mode 100644 index 0000000..48a7064 --- /dev/null +++ b/layouts/blog_article.html @@ -0,0 +1,81 @@ +<!DOCTYPE html> +<html> +<head> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> + <link rel="stylesheet" href="../../css/default.css"> + <link rel="stylesheet" href="../../css/blog_article.css"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="icon" type="image/png" href="../../imgs/logo.png" /> + <title><%= @item[:title] %></title> + <meta charset="UTF-8"> +</head> +<body> + +<nav class="topnav"> + <div class="progress-container"> + <div class="progress-bar" id="scrollindicator"></div> + </div> + <div> + <%= link_to('ホーム', '/index.html', {class: 'left'}) %> + <%= link_to('詳細', '/about.html', {class: 'right'}) %> + <div class="outer-title"><div class="inner-title">水瓶 — <%= @item[:title] %></div></div> + </div> +</nav> + + +<div id="wrapper"> +<aside id="left"></aside> +<div class="art"> +<div id="content"> + <%= get_content(yield) %> +</div> +</div> + <div style="clear: both"></div> + <div style="float: left;">日付: <%= @item[:created_at] %></div> + <div style="float: right">タグ: <%= @item[:tags].join("・") %></div> +<aside id="right"><%= get_toc(yield) %></aside> +</div> + +<footer></footer> +<script> +window.onscroll = function() { scrollUpdate(); sectionUpdate(); }; + +var section = document.querySelectorAll("div.section a.toc-backref"); +var sectionLinks = document.querySelectorAll("div.contents a.reference"); +var sections = {}; +var i = 0; + +Array.prototype.forEach.call(section, function(e) { + sections[e.href.split('#')[1]] = e.offsetTop - 0.5 * document.documentElement.clientHeight; +}); + +Array.prototype.forEach.call(sectionLinks, function(e) { + e.onclick = function () { + setTimeout(function(){ + var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop; + window.scrollTo(0, scrollPosition - 48) + }, 1); + } +}); + +document.querySelector("div.contents a.reference").classList.add('active-section'); + +function scrollUpdate() { + var winScroll = document.body.scrollTop || document.documentElement.scrollTop; + var height = document.documentElement.scrollHeight - document.documentElement.clientHeight; + var scrolled = (winScroll / height) * 100; + document.getElementById("scrollindicator").style.width = scrolled + "%"; +} + +function sectionUpdate() { + var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop; + for (i in sections) { + if (sections[i] <= scrollPosition) { + document.querySelector('.active-section').classList.remove('active-section'); + document.querySelector('a[id=' + i + ']').classList.add('class', 'active-section'); + } + } +}; +</script> +</body> +</html> |
