Skip to content

Commit

Permalink
update category functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Euijong Joo committed Jan 8, 2020
1 parent b509158 commit 981fc0e
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 18 deletions.
11 changes: 2 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
ffi (1.11.3)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
i18n (1.7.0)
i18n (1.7.1)
concurrent-ruby (~> 1.0)
jekyll (4.0.0)
addressable (~> 2.4)
Expand All @@ -33,8 +33,6 @@ GEM
jekyll (>= 3.7, < 5.0)
jekyll-sass-converter (2.0.1)
sassc (> 2.0.1, < 3.0)
jekyll-seo-tag (2.6.1)
jekyll (>= 3.3, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.1.0)
Expand All @@ -45,13 +43,9 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.2)
public_suffix (4.0.3)
rb-fsevent (0.10.3)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand All @@ -75,7 +69,6 @@ PLATFORMS
DEPENDENCIES
jekyll (~> 4.0.0)
jekyll-feed (~> 0.12)
minima (~> 2.5)
tzinfo (~> 1.2)
tzinfo-data
wdm (~> 0.1.1)
Expand Down
48 changes: 48 additions & 0 deletions _includes/category.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<article class="post">
<header class="post-header home">
<div class="post-title">Category - <span id='category-name'></span></div>
</header>

<div class="post-content">
{%- if site.posts.size > 0 -%}
<ul class="post-list">
{%- for post in site.posts -%}
<li class="post-list-item post-category-{{post.categories}}">
<!-- {%- assign date_format = site.date_format | default: "%b %-d, %Y" -%} -->
{%- assign date_format = "%Y/%m/%d" -%}
<span class="post-date">{{ post.date | date: date_format }}</span>
<a class="post-link" href="{{ post.url | relative_url }}">
{{ post.title | escape }}
</a>
{%- if site.show_excerpts -%}{{ post.excerpt }}{%- endif -%}
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</div>
</article>

<script src="/public/js/jquery-3.4.1.slim.min.js"></script>
<script>
function removeCategory() {
if (window.location.hash) {
let hash = window.location.hash.substring(1);
$('#category-name').text(hash.substring(0, 1).toUpperCase() + hash.substring(1));
let category_class = '.post-category-' + hash;
let items = $('.post-list-item').each((i, e) => {
if (!$(e).hasClass('post-category-' + hash)) {
$(e).hide();
} else {
$(e).show();
}
});
}
}
$(window).on('hashchange', () => {
removeCategory();
});
$(document).ready(() => {
removeCategory();
})

</script>
2 changes: 1 addition & 1 deletion _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<div class="sidebar-item sidebar-nav">
<ul class="nav">
<li class="nav-title">Tags</li>
<li class="nav-title">Categories</li>
{% for category in site.categories %}
<li>
<a class="nav-item" href="{{ root_url }}/{{ site.category_dir }}#{{ category | first }}">
Expand Down
4 changes: 4 additions & 0 deletions _layouts/category.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
layout: default
---
{%- include category.html -%}
2 changes: 1 addition & 1 deletion category.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: post
layout: category
title: Category
permalink: /category/
---
13 changes: 6 additions & 7 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import url(//fonts.googleapis.com/css?family=Ubuntu:500&subset=latin,latin-ext);
@import url('https://fonts.googleapis.com/css?family=Gelasio|Kulim+Park|Nanum+Myeongjo|Nanum+Gothic|Noto+Sans|Noto+Sans+KR|Roboto&display=swap');
@import url(syntax/monokai.css);

:root {
--blue: #007bff;
Expand Down Expand Up @@ -153,13 +154,6 @@ a.nav-item:hover { color: #777; }
.post-list > li {
}

span.post-date {
text-transform: uppercase;
font-size: 80%;
color: #555;
letter-spacing: 1px;
}

.post-link {
margin-left: 10px;
font-size: 110%;
Expand Down Expand Up @@ -274,7 +268,12 @@ header.home {
}

.post-date {
text-transform: uppercase;
color: #555;
letter-spacing: 1px;
font-size: 0.8em;
display: inline-block;
width: 80px;
}

.author .author-image {
Expand Down
40 changes: 40 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(function($) {

function init() {
/* Sidebar height set */
$sidebarStyles = $('.sidebar').attr('style') || "";
$sidebarStyles += ' min-height: ' + $(document).height() + 'px;';
$('.sidebar').attr('style', $sidebarStyles);

/* Secondary contact links */
var $scontacts = $('#contact-list-secondary');
var $contactList = $('#contact-list');

$scontacts.hide();
$contactList.mouseenter(function(){ $scontacts.fadeIn(); });
$contactList.mouseleave(function(){ $scontacts.fadeOut(); });

/**
* Tags & categories tab activation based on hash value. If hash is undefined then first tab is activated.
*/
function activateTab() {
if(['/tags.html', '/categories.html'].indexOf(window.location.pathname) > -1) {
var hash = window.location.hash;
if(hash)
$('.tab-pane').length && $('a[href="' + hash + '"]').tab('show');
else
$('.tab-pane').length && $($('.cat-tag-menu li a')[0]).tab('show');
}
}

// watch hash change and activate relevant tab
$(window).on('hashchange', activateTab);

// initial activation
activateTab();
};

// run init on document ready
$(document).ready(init);

})(jQuery);
6 changes: 6 additions & 0 deletions public/js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/jquery-3.4.1.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/js/jquery-3.4.1.slim.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions public/js/jquery.min.js

Large diffs are not rendered by default.

0 comments on commit 981fc0e

Please sign in to comment.