Skip to content

Commit b82f909

Browse files
committed
update: modify the index structure
1 parent aa98952 commit b82f909

File tree

5 files changed

+190
-71
lines changed

5 files changed

+190
-71
lines changed

assets/css/main.css

Lines changed: 124 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,146 @@
1-
.home-content {
2-
max-width: 1200px;
3-
margin: 0 auto;
1+
/* 基础样式 */
2+
body {
3+
margin: 0;
4+
padding: 0;
5+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
6+
}
7+
8+
/* 主布局 */
9+
.site-container {
10+
display: flex;
11+
min-height: 100vh;
12+
}
13+
14+
/* 左侧导航栏 */
15+
.sidebar {
16+
width: 250px;
17+
background: #2c3e50;
18+
color: white;
419
padding: 2rem;
20+
position: fixed;
21+
height: 100vh;
22+
overflow-y: auto;
523
}
624

7-
.category-section {
8-
margin: 2rem 0;
9-
padding: 1rem;
10-
background: #f5f5f5;
11-
border-radius: 8px;
25+
.sidebar h1 {
26+
margin: 0 0 2rem;
27+
font-size: 1.5rem;
1228
}
1329

14-
.category-section h2 {
15-
color: #333;
16-
border-bottom: 2px solid #ddd;
17-
padding-bottom: 0.5rem;
30+
.sidebar nav ul {
31+
list-style: none;
32+
padding: 0;
33+
margin: 0;
1834
}
1935

36+
.sidebar nav li {
37+
margin: 0.5rem 0;
38+
}
39+
40+
.sidebar nav a {
41+
color: white;
42+
text-decoration: none;
43+
display: block;
44+
padding: 0.5rem;
45+
border-radius: 4px;
46+
transition: background-color 0.2s;
47+
}
48+
49+
.sidebar nav a:hover {
50+
background: #34495e;
51+
}
52+
53+
/* 右侧内容区 */
54+
.main-content {
55+
flex: 1;
56+
margin-left: 250px;
57+
padding: 2rem;
58+
min-height: calc(100vh - 100px);
59+
}
60+
61+
/* 文章卡片 */
2062
.post-list {
2163
display: grid;
2264
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
2365
gap: 1.5rem;
24-
margin-top: 1rem;
2566
}
2667

2768
.post-item {
2869
background: white;
29-
padding: 1rem;
30-
border-radius: 6px;
70+
padding: 1.5rem;
71+
border-radius: 8px;
3172
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
73+
transition: transform 0.2s;
74+
}
75+
76+
.post-item:hover {
77+
transform: translateY(-2px);
3278
}
3379

3480
.post-item h3 {
35-
margin: 0 0 0.5rem;
81+
margin: 0 0 1rem;
3682
}
3783

3884
.post-item a {
3985
color: #2c3e50;
4086
text-decoration: none;
4187
}
4288

43-
.post-item a:hover {
44-
color: #42b983;
45-
}
46-
4789
.post-meta {
4890
font-size: 0.9rem;
4991
color: #666;
50-
margin-bottom: 0.5rem;
92+
margin-bottom: 1rem;
5193
}
5294

5395
.tags a {
5496
display: inline-block;
55-
margin-left: 0.5rem;
56-
color: #42b983;
97+
padding: 0.2rem 0.5rem;
98+
margin: 0.2rem;
99+
background: #f0f0f0;
100+
border-radius: 3px;
101+
color: #666;
102+
text-decoration: none;
103+
font-size: 0.8rem;
57104
}
58105

59-
.description {
60-
font-size: 0.9rem;
61-
color: #666;
62-
margin: 0.5rem 0 0;
106+
.tags a:hover {
107+
background: #e0e0e0;
63108
}
64109

65-
/* 在现有样式后添加 */
110+
/* 语言切换 */
66111
.language-switch {
67-
margin-left: auto;
112+
margin-top: 2rem;
113+
padding-top: 1rem;
114+
border-top: 1px solid rgba(255, 255, 255, 0.1);
68115
}
69116

70117
.lang-item {
71-
padding: 4px 8px;
72-
border-radius: 4px;
73-
background: #42b983;
74118
color: white;
75119
text-decoration: none;
120+
padding: 0.5rem;
121+
border-radius: 4px;
122+
background: rgba(255, 255, 255, 0.1);
76123
}
77124

78125
.lang-item:hover {
79-
background: #3aa876;
126+
background: rgba(255, 255, 255, 0.2);
127+
}
128+
129+
.home-content {
130+
max-width: 1200px;
131+
margin: 0 auto;
132+
padding: 2rem;
133+
}
134+
135+
.category-section {
136+
margin-bottom: 3rem;
137+
}
138+
139+
.category-section h3 {
140+
color: #2c3e50;
141+
margin-bottom: 1.5rem;
142+
padding-bottom: 0.5rem;
143+
border-bottom: 2px solid #eee;
80144
}
81145

82146
nav ul {
@@ -89,4 +153,31 @@ nav ul {
89153

90154
nav ul li {
91155
margin: 0 1rem;
156+
}
157+
158+
/* 添加内容头部样式 */
159+
.content-header {
160+
margin-bottom: 2rem;
161+
padding-bottom: 1rem;
162+
border-bottom: 2px solid #eee;
163+
}
164+
165+
.content-header h2 {
166+
margin: 0 0 1rem;
167+
color: #2c3e50;
168+
}
169+
170+
.content-header p {
171+
color: #666;
172+
margin: 0;
173+
}
174+
175+
/* 在文件末尾添加 footer 样式 */
176+
footer {
177+
margin-left: 250px;
178+
padding: 2rem;
179+
background: #f5f5f5;
180+
text-align: center;
181+
font-size: 0.9rem;
182+
color: #666;
92183
}

config.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,29 @@ name = "技术解析"
3535
url = "/categories/technologies/"
3636
weight = 2
3737
[[menu.main]]
38-
name = "项目分享"
39-
url = "/categories/projects/"
38+
name = "模型训练"
39+
url = "/categories/training/"
4040
weight = 3
4141
[[menu.main]]
42+
name = "开源项目"
43+
url = "/categories/opensource/"
44+
weight = 4
45+
[[menu.main]]
4246
name = "人物访谈"
4347
url = "/categories/interviews/"
44-
weight = 4
48+
weight = 5
4549
[[menu.main]]
4650
name = "行业动态"
4751
url = "/categories/news/"
48-
weight = 5
52+
weight = 6
53+
[[menu.main]]
54+
name = "行业规范"
55+
url = "/categories/spec/"
56+
weight = 7
4957
[[menu.main]]
5058
name = "产品介绍"
5159
url = "/categories/products/"
52-
weight = 6
60+
weight = 8
5361

5462
[outputs]
5563
home = ["HTML"]

layouts/_default/baseof.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
</head>
99

1010
<body>
11-
{{ partial "header.html" . }}
12-
<main>
13-
{{ block "main" . }}{{ end }}
14-
</main>
11+
{{ block "main" . }}{{ end }}
1512
{{ partial "footer.html" . }}
1613
</body>
1714

layouts/index.html

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
{{ define "main" }}
2-
<div class="home-content">
3-
<h1>{{ .Site.Title }}</h1>
4-
<p>{{ .Site.Params.description }}</p>
2+
<div class="site-container">
3+
<!-- 左侧导航栏 -->
4+
<aside class="sidebar">
5+
<h1>{{ .Site.Title }}</h1>
6+
<nav>
7+
<ul>
8+
<li><a href="{{ " /" | relLangURL }}">{{ i18n "home" }}</a></li>
9+
{{ range .Site.Menus.main }}
10+
<li><a href="{{ .URL | relLangURL }}">{{ .Name }}</a></li>
11+
{{ end }}
12+
</ul>
13+
</nav>
14+
<div class="language-switch">
15+
{{ range .Site.Languages }}
16+
{{ if ne .Lang $.Site.Language.Lang }}
17+
<a href="{{ .Lang | relLangURL }}" class="lang-item">{{ .LanguageName }}</a>
18+
{{ end }}
19+
{{ end }}
20+
</div>
21+
</aside>
522

6-
<!-- 按分类显示文章 -->
7-
{{ $categories := slice "papers" "technologies" "projects" "interviews" "news" "products" }}
23+
<!-- 右侧内容区 -->
24+
<main class="main-content">
25+
<div class="content-header">
26+
<h2>{{ i18n "categories" }}</h2>
27+
<p>{{ .Site.Params.description }}</p>
28+
</div>
829

9-
{{ range $categories }}
10-
{{ $category := . }}
11-
<section class="category-section">
12-
<h2>{{ i18n . }}</h2>
13-
<div class="post-list">
14-
{{ range where $.Site.RegularPages "Params.categories" "intersect" (slice $category) }}
15-
<article class="post-item">
16-
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
17-
<div class="post-meta">
18-
<time>{{ .Date.Format "2006-01-02" }}</time>
19-
{{ with .Params.tags }}
20-
<span class="tags">
21-
{{ range . }}
22-
<a href="/tags/{{ . | urlize }}">#{{ . }}</a>
30+
{{ range .Site.Menus.main }}
31+
{{ $category := .Identifier }}
32+
<section class="category-section">
33+
<h3>{{ .Name }}</h3>
34+
<div class="post-list">
35+
{{ range where $.Site.RegularPages "Params.categories" "intersect" (slice $category) }}
36+
<article class="post-item">
37+
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
38+
<div class="post-meta">
39+
<time>{{ .Date.Format "2006-01-02" }}</time>
40+
{{ with .Params.tags }}
41+
<div class="tags">
42+
{{ range . }}
43+
<a href="/tags/{{ . | urlize }}">#{{ . }}</a>
44+
{{ end }}
45+
</div>
2346
{{ end }}
24-
</span>
47+
</div>
48+
{{ with .Description }}
49+
<p class="description">{{ . }}</p>
2550
{{ end }}
26-
</div>
27-
{{ with .Description }}
28-
<p class="description">{{ . }}</p>
51+
</article>
2952
{{ end }}
30-
</article>
31-
{{ end }}
32-
</div>
33-
</section>
34-
{{ end }}
53+
</div>
54+
</section>
55+
{{ end }}
56+
</main>
3557
</div>
3658
{{ end }}

layouts/partials/footer.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<footer>
22
<p>&copy; {{ now.Format "2006" }} {{ .Site.Title }}. All rights reserved.</p>
33
<p>
4-
如有反馈,欢迎通过 <a href="https://github.com/yourusername/yourrepo/issues" target="_blank">GitHub Issue</a> 提交。
4+
<a href="https://github.com/hobbytp/hobbytp.github.io" target="_blank">GitHub</a> |
5+
<a href="https://github.com/hobbytp/hobbytp.github.io/issues" target="_blank">反馈</a>
56
</p>
67
</footer>

0 commit comments

Comments
 (0)