基本样式测试

This commit is contained in:
2025-11-23 21:48:11 +08:00
parent 86b28ed215
commit a469da2904
8 changed files with 126 additions and 90 deletions

View File

@@ -1,12 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document</title>
</head>
<body>
<h2>{{.title}}</h2>
</body>
</html>

View File

@@ -1,12 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document</title>
</head>
<body>
<h2>我是一个新闻界面</h2>
</body>
</html>

View File

@@ -0,0 +1,17 @@
{{ define "layout/base.html" }}
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>{{ block "title" . }}默认标题{{ end }}</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
{{ template "layout/navbar.html" . }}
<main>
{{ block "content" . }}{{ end }}
</main>
</body>
</html>
{{ end }}

View File

@@ -0,0 +1,11 @@
{{ define "layout/navbar.html" }}
<nav class="navbar">
<div class="logo">🔥 NanNanWu</div>
<ul class="nav-links">
<li><a href="/">首页</a></li>
<li><a href="/about">关于我们</a></li>
<li><a href="/articles">文章</a></li>
<li><a href="/contact">联系</a></li>
</ul>
</nav>
{{ end }}

View File

@@ -1,12 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document</title>
</head>
<body>
<h2>{{.title}}</h2>
</body>
</html>

View File

@@ -0,0 +1,9 @@
{{ define "pages/index.html" }}
{{ template "layout/base.html" . }}
{{ block "title" . }}首页{{ end }}
{{ block "content" . }}
<h1>欢迎来到我的 Gin 网站</h1>
<p>这里是首页内容,可以展示最新文章或公告。</p>
{{ end }}
{{ end }}