hexo cateory 꾸미기

hexo의 Next 테마에서 카테고리 화면이 이쁘지 않아서 수정한 내용을 정리한다.

Next 테마의 카테고리 화면의 불만

카테고리 화면이 다음과같이 일반 리스트로 나오는것이 불만이었다.

일반리스트로 나오다보니 뭔가 좀 허전 ㅠㅠ

next 테마의 카테고리 관련 파일들

next 테마에서 category 페이지에 관련한 파일은 다음과같다.

1
2
\themes\next\layout\page.swig
\themes\next\source\css\_common\components\pages\categories.styl
  • page.swig : 페이지의 layout, css class 들에 대한 정의
  • categories.styl : category 페이지의 css style

Next 테마에서 category page 수정하기

css 만으로 카테고리의 계층 표현하기

JS 니 뭐니 덕지덕지 붙는게 싫기도 하고, 그냥 간단하게 표현하고싶었다. 그래서 CSS만으로 카테고리 계층을 표현한 예제파일들중에 가장 간단한것을 소개한다. (직접작성 할 능력은 안되니 그냥 검색후 붙이는것으로 한다 .. ;;)

예제프로젝트

CSS 으로만 카테고리 계층도 표현가능하다.

Next theme 수정

\themes\next\layout\page.swig 의 내용을 다음과같이 수정한다.

  • list_categories() 부분을 다음과 같이 수정
1
2
3
4
5
6
7
8
9
10
11
12
# \themes\next\layout\page.swig

## 생략

<div class="category-all">
<ul class="tree">
Cateogry
{{ list_categories() }}
</ul>
</div>

## 생략..

\themes\next\source\css\_common\components\pages\categories.styl 의 내용을 다음과같이 수정한다.

  • 스타일 수정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.category-all-page {
.category-all-title { text-align: center; }

.category-all { margin-top: 20px; }

.category-list {
margin: 0;
padding-left: 80px;
list-style: none;
}

.category-list a {
color: #0046af;
font-weight: normal;
border-bottom:none;
}

.category-list-item { margin: 5px 10px; list-style: none;}

.category-list-count {
color: $grey;
&:before {
display: inline;
content: " ("
}
&:after {
display: inline;
content: ") "
}
}

.category-list-child { padding-left: 10px; }

.category-list ul li{
list-style: none;
margin-left: 10px;
}

.category-list-item ul li {
list-style: none;
margin-left: 10px;
}

ul.tree, ul.tree ul {
list-style: none;
margin: 0;
padding: 0;
}
ul.tree ul {
margin-left: 10px;
list-style: none;
}
ul.tree li {
margin: 0;
padding-left: 7px;
line-height: 20px;
color: #369;
font-weight: bold;
border-left:1px solid rgb(100,100,100);
list-style: none;
padding-top : 10px;
}
ul.tree li:last-child {
border-left:none;
}
ul.tree li:before {
position:relative;
top:-0.3em;
height:1em;
width:12px;
color:white;
border-bottom:1px solid rgb(100,100,100);
content:"";
display:inline-block;
left:-7px;
}
ul.tree li:last-child:before {
border-left:1px solid rgb(100,100,100);
}
}

Next 테마에서 category page 수정완료

수정후

  • 수정후

간단하게 몇줄 추가하여 깔끔하게 수정완료.

0%