chore: refine responsive layout and post timestamps
This commit is contained in:
138
worker.js
138
worker.js
@@ -369,7 +369,11 @@ function renderPostCard(post) {
|
||||
<article class="post-card">
|
||||
<h2><a href="/post/${encodeURIComponent(post.slug)}">${escapeHtml(post.title)}</a></h2>
|
||||
<p class="post-excerpt">${escapeHtml(excerpt)}${excerpt.length >= 180 ? "…" : ""}</p>
|
||||
<p class="post-meta"><span class="post-card-time">${formatDateTime(post.updated_at)}</span><span class="post-card-views">浏览 ${views}</span></p>
|
||||
<p class="post-meta">
|
||||
<span class="post-card-time">创建时间:${formatDateTime(post.created_at)}</span>
|
||||
<span class="post-card-time">最后更新时间:${formatDateTime(post.updated_at)}</span>
|
||||
<span class="post-card-views">浏览 ${views}</span>
|
||||
</p>
|
||||
</article>
|
||||
`;
|
||||
}
|
||||
@@ -406,18 +410,47 @@ function renderLayout(title, body, env, options = {}) {
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
|
||||
<title>${escapeHtml(title)}</title>
|
||||
<link rel="icon" href="/favicon.ico" sizes="any">
|
||||
${mdHead}
|
||||
<style>
|
||||
html, body { margin: 0; padding: 0; background: #fff; color: #111; }
|
||||
body { font-family: Arial, sans-serif; line-height: 1.7; }
|
||||
main { max-width: 820px; margin: 0 auto; padding: 16px; }
|
||||
:root {
|
||||
--page-max: 920px;
|
||||
--page-pad-x: 24px;
|
||||
--page-pad-y: 24px;
|
||||
--page-gap: 24px;
|
||||
--text: #111;
|
||||
--muted: #555;
|
||||
--line: #e8e8e8;
|
||||
}
|
||||
html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
color: var(--text);
|
||||
-webkit-text-size-adjust: 100%;
|
||||
text-size-adjust: 100%;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
color: var(--text);
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.7;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
main {
|
||||
width: min(100%, var(--page-max));
|
||||
margin: 0 auto;
|
||||
padding: var(--page-pad-y) var(--page-pad-x) 32px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
header.site-header {
|
||||
margin-bottom: 24px;
|
||||
margin-bottom: var(--page-gap);
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.site-brand {
|
||||
display: flex;
|
||||
@@ -428,7 +461,8 @@ function renderLayout(title, body, env, options = {}) {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
font-weight: 700;
|
||||
font-size: 1.2rem;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.site-logo {
|
||||
flex-shrink: 0;
|
||||
@@ -445,30 +479,50 @@ function renderLayout(title, body, env, options = {}) {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
padding: 16px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.admin-gate[hidden] { display: none !important; }
|
||||
.admin-gate-panel {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
padding: 16px 18px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #ccc;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
max-width: 92vw;
|
||||
width: min(100%, 420px);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.admin-gate-panel input[type="password"] { width: min(220px, 70vw); box-sizing: border-box; }
|
||||
h1, h2, h3 { line-height: 1.3; margin: 0 0 12px; }
|
||||
.admin-gate-panel input[type="password"] {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-width: 0;
|
||||
}
|
||||
h1, h2, h3 { line-height: 1.3; margin: 0 0 12px; word-break: break-word; }
|
||||
article, section { margin: 0 0 24px; }
|
||||
p { margin: 0 0 12px; }
|
||||
p { margin: 0 0 12px; word-break: break-word; }
|
||||
a { color: inherit; }
|
||||
input, textarea, button { font: inherit; }
|
||||
input[type="text"], textarea { width: 100%; box-sizing: border-box; }
|
||||
textarea { min-height: 320px; }
|
||||
pre { white-space: pre-wrap; word-break: break-word; }
|
||||
input, textarea, button {
|
||||
font: inherit;
|
||||
max-width: 100%;
|
||||
}
|
||||
input[type="text"], input[type="password"], textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-width: 0;
|
||||
}
|
||||
textarea { min-height: 320px; resize: vertical; }
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
overflow-x: auto;
|
||||
}
|
||||
img { max-width: 100%; height: auto; }
|
||||
hr { border: 0; border-top: 1px solid #ddd; margin: 24px 0; }
|
||||
.post-card { padding-bottom: 16px; border-bottom: 1px solid #efefef; }
|
||||
.post-card:last-of-type { padding-bottom: 0; border-bottom: 0; }
|
||||
.post-card .post-excerpt { margin: 0 0 10px; }
|
||||
.post-card .post-meta {
|
||||
font-size: 0.9em;
|
||||
@@ -490,9 +544,53 @@ function renderLayout(title, body, env, options = {}) {
|
||||
}
|
||||
.post-detail-views { color: #666; }
|
||||
form { margin: 0; }
|
||||
@media (max-width: 640px) {
|
||||
main { padding: 12px; }
|
||||
@media (max-width: 1024px) {
|
||||
:root {
|
||||
--page-max: 840px;
|
||||
--page-pad-x: 20px;
|
||||
--page-pad-y: 20px;
|
||||
--page-gap: 20px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
:root {
|
||||
--page-max: 100%;
|
||||
--page-pad-x: 16px;
|
||||
--page-pad-y: 16px;
|
||||
--page-gap: 18px;
|
||||
}
|
||||
.site-logo { width: 36px; height: 36px; }
|
||||
.site-title-link { font-size: 1.1rem; }
|
||||
.post-card .post-meta,
|
||||
.post-detail-meta {
|
||||
gap: 6px 12px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
:root {
|
||||
--page-pad-x: 14px;
|
||||
--page-pad-y: 14px;
|
||||
--page-gap: 16px;
|
||||
}
|
||||
body { line-height: 1.68; }
|
||||
header.site-header { padding-bottom: 12px; }
|
||||
textarea { min-height: 240px; }
|
||||
.site-brand {
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.site-logo { width: 32px; height: 32px; }
|
||||
.site-title-link { font-size: 1rem; }
|
||||
.post-card .post-meta,
|
||||
.post-detail-meta {
|
||||
font-size: 0.88em;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
}
|
||||
.admin-gate-panel {
|
||||
padding: 14px 14px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user