Upload 3 files
Browse files- blogs.js +27 -13
- index.html +7 -8
- styles.css +15 -7
blogs.js
CHANGED
|
@@ -50,22 +50,37 @@ const posts = [
|
|
| 50 |
}
|
| 51 |
];
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
const postList = document.querySelector("[data-post-list]");
|
| 54 |
const categoryList = document.querySelector("[data-category-list]");
|
| 55 |
const countLabel = document.querySelector("[data-post-count]");
|
| 56 |
|
| 57 |
-
const formatDate = (date) => {
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
const categories = [
|
| 63 |
|
| 64 |
-
function renderCategories(activeCategory =
|
| 65 |
categoryList.innerHTML = categories
|
| 66 |
.map((category) => `
|
| 67 |
<button class="filter-button ${category === activeCategory ? "is-active" : ""}" type="button" data-category="${category}">
|
| 68 |
-
${category}
|
| 69 |
</button>
|
| 70 |
`)
|
| 71 |
.join("");
|
|
@@ -75,27 +90,26 @@ function renderCategories(activeCategory = "全部") {
|
|
| 75 |
});
|
| 76 |
}
|
| 77 |
|
| 78 |
-
function renderPosts(activeCategory =
|
| 79 |
-
const visiblePosts = activeCategory ===
|
| 80 |
? posts
|
| 81 |
: posts.filter((post) => post.category === activeCategory);
|
| 82 |
|
| 83 |
renderCategories(activeCategory);
|
| 84 |
-
countLabel.textContent = `${visiblePosts.length}
|
| 85 |
postList.innerHTML = visiblePosts.map((post) => `
|
| 86 |
<article class="post-card">
|
| 87 |
<a class="post-image" href="${post.url}" target="_blank" rel="noopener">
|
| 88 |
<img src="${post.cover}" alt="${post.title}" loading="lazy">
|
| 89 |
</a>
|
| 90 |
<div class="post-content">
|
| 91 |
-
<div class="post-meta"><span class="tag">${post.category}</span><time datetime="${post.date}">${formatDate(post.date)}</time></div>
|
| 92 |
<h2><a href="${post.url}" target="_blank" rel="noopener">${post.title}</a></h2>
|
| 93 |
<p>${post.excerpt}</p>
|
| 94 |
-
<a class="read-link" href="${post.url}" target="_blank" rel="noopener">
|
| 95 |
</div>
|
| 96 |
</article>
|
| 97 |
`).join("");
|
| 98 |
}
|
| 99 |
|
| 100 |
renderPosts();
|
| 101 |
-
|
|
|
|
| 50 |
}
|
| 51 |
];
|
| 52 |
|
| 53 |
+
const categoryLabels = {
|
| 54 |
+
"产品方案": "Product Solutions",
|
| 55 |
+
"功能更新": "Feature Updates",
|
| 56 |
+
"解决方案": "Solutions",
|
| 57 |
+
"深度洞察": "Insights",
|
| 58 |
+
"客户案例": "Customer Stories",
|
| 59 |
+
"操作指引": "Guides",
|
| 60 |
+
"干货分享": "Practical Insights"
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
const ALL_CATEGORY = "__all__";
|
| 64 |
+
|
| 65 |
const postList = document.querySelector("[data-post-list]");
|
| 66 |
const categoryList = document.querySelector("[data-category-list]");
|
| 67 |
const countLabel = document.querySelector("[data-post-count]");
|
| 68 |
|
| 69 |
+
const formatDate = (date) => new Intl.DateTimeFormat("en-US", {
|
| 70 |
+
year: "numeric",
|
| 71 |
+
month: "short",
|
| 72 |
+
day: "numeric"
|
| 73 |
+
}).format(new Date(`${date}T00:00:00`));
|
| 74 |
+
|
| 75 |
+
const categoryLabel = (category) => categoryLabels[category] || category;
|
| 76 |
|
| 77 |
+
const categories = [ALL_CATEGORY, ...new Set(posts.map((post) => post.category))];
|
| 78 |
|
| 79 |
+
function renderCategories(activeCategory = ALL_CATEGORY) {
|
| 80 |
categoryList.innerHTML = categories
|
| 81 |
.map((category) => `
|
| 82 |
<button class="filter-button ${category === activeCategory ? "is-active" : ""}" type="button" data-category="${category}">
|
| 83 |
+
${category === ALL_CATEGORY ? "All" : categoryLabel(category)}
|
| 84 |
</button>
|
| 85 |
`)
|
| 86 |
.join("");
|
|
|
|
| 90 |
});
|
| 91 |
}
|
| 92 |
|
| 93 |
+
function renderPosts(activeCategory = ALL_CATEGORY) {
|
| 94 |
+
const visiblePosts = activeCategory === ALL_CATEGORY
|
| 95 |
? posts
|
| 96 |
: posts.filter((post) => post.category === activeCategory);
|
| 97 |
|
| 98 |
renderCategories(activeCategory);
|
| 99 |
+
countLabel.textContent = `${visiblePosts.length} articles`;
|
| 100 |
postList.innerHTML = visiblePosts.map((post) => `
|
| 101 |
<article class="post-card">
|
| 102 |
<a class="post-image" href="${post.url}" target="_blank" rel="noopener">
|
| 103 |
<img src="${post.cover}" alt="${post.title}" loading="lazy">
|
| 104 |
</a>
|
| 105 |
<div class="post-content">
|
| 106 |
+
<div class="post-meta"><span class="tag">${categoryLabel(post.category)}</span><time datetime="${post.date}">${formatDate(post.date)}</time></div>
|
| 107 |
<h2><a href="${post.url}" target="_blank" rel="noopener">${post.title}</a></h2>
|
| 108 |
<p>${post.excerpt}</p>
|
| 109 |
+
<a class="read-link" href="${post.url}" target="_blank" rel="noopener">Read full article <span aria-hidden="true">↗</span></a>
|
| 110 |
</div>
|
| 111 |
</article>
|
| 112 |
`).join("");
|
| 113 |
}
|
| 114 |
|
| 115 |
renderPosts();
|
|
|
index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
-
<meta name="description" content="3chat.ai
|
| 7 |
<title>3chat.ai Blog</title>
|
| 8 |
<link rel="icon" href="https://www.3chatai.cn/blog/favicon.ico?favicon.120on8qamd06b.ico" type="image/x-icon">
|
| 9 |
<link rel="stylesheet" href="styles.css">
|
|
@@ -14,23 +14,22 @@
|
|
| 14 |
<div class="brand-lockup">
|
| 15 |
<img
|
| 16 |
class="site-logo"
|
| 17 |
-
src="https://www.3chatai.cn/
|
| 18 |
-
alt="3Chat.ai
|
| 19 |
-
onerror="this.style.display='none'; this.nextElementSibling.style.display='block'"
|
| 20 |
>
|
| 21 |
<strong class="logo-fallback">3chat.ai</strong>
|
| 22 |
-
<h1>3chat.ai</h1>
|
| 23 |
</div>
|
| 24 |
-
<p class="brand-tagline">
|
| 25 |
</header>
|
| 26 |
|
| 27 |
<section aria-labelledby="posts-title">
|
| 28 |
<div class="section-heading">
|
| 29 |
-
<h2 id="posts-title">
|
| 30 |
<span class="post-count" data-post-count></span>
|
| 31 |
</div>
|
| 32 |
|
| 33 |
-
<div class="filters" data-category-list aria-label="
|
| 34 |
<div class="post-list" data-post-list></div>
|
| 35 |
</section>
|
| 36 |
</main>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<meta name="description" content="3chat.ai product, technology, model, and dataset updates.">
|
| 7 |
<title>3chat.ai Blog</title>
|
| 8 |
<link rel="icon" href="https://www.3chatai.cn/blog/favicon.ico?favicon.120on8qamd06b.ico" type="image/x-icon">
|
| 9 |
<link rel="stylesheet" href="styles.css">
|
|
|
|
| 14 |
<div class="brand-lockup">
|
| 15 |
<img
|
| 16 |
class="site-logo"
|
| 17 |
+
src="https://www.3chatai.cn/images/3Chat.ai_Logo.svg"
|
| 18 |
+
alt="3Chat.ai official logo"
|
| 19 |
+
onerror="if (!this.dataset.fallback) { this.dataset.fallback='1'; this.src='https://www.3chatai.cn/blog/images/3Chat.ai_Logo.svg'; } else { this.style.display='none'; this.nextElementSibling.style.display='block'; }"
|
| 20 |
>
|
| 21 |
<strong class="logo-fallback">3chat.ai</strong>
|
|
|
|
| 22 |
</div>
|
| 23 |
+
<p class="brand-tagline">Turn every upgrade to our models, data, and products into lasting knowledge.</p>
|
| 24 |
</header>
|
| 25 |
|
| 26 |
<section aria-labelledby="posts-title">
|
| 27 |
<div class="section-heading">
|
| 28 |
+
<h2 id="posts-title">Articles</h2>
|
| 29 |
<span class="post-count" data-post-count></span>
|
| 30 |
</div>
|
| 31 |
|
| 32 |
+
<div class="filters" data-category-list aria-label="Filter articles by category"></div>
|
| 33 |
<div class="post-list" data-post-list></div>
|
| 34 |
</section>
|
| 35 |
</main>
|
styles.css
CHANGED
|
@@ -53,6 +53,11 @@ button {
|
|
| 53 |
display: flex;
|
| 54 |
align-items: center;
|
| 55 |
gap: 22px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
}
|
| 57 |
|
| 58 |
.site-logo {
|
|
@@ -67,6 +72,7 @@ button {
|
|
| 67 |
display: none;
|
| 68 |
font-size: 1.6rem;
|
| 69 |
letter-spacing: -0.04em;
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
h1,
|
|
@@ -79,6 +85,7 @@ h2 {
|
|
| 79 |
h1 {
|
| 80 |
margin: 0;
|
| 81 |
font-size: clamp(2.4rem, 6vw, 4rem);
|
|
|
|
| 82 |
}
|
| 83 |
|
| 84 |
.brand-tagline {
|
|
@@ -113,18 +120,19 @@ h1 {
|
|
| 113 |
}
|
| 114 |
|
| 115 |
.filter-button {
|
| 116 |
-
padding:
|
| 117 |
-
border: 1px solid
|
| 118 |
-
border-radius:
|
| 119 |
-
background:
|
| 120 |
color: var(--muted);
|
|
|
|
| 121 |
cursor: pointer;
|
| 122 |
}
|
| 123 |
|
| 124 |
.filter-button:hover,
|
| 125 |
.filter-button.is-active {
|
| 126 |
-
border-color: #
|
| 127 |
-
background:
|
| 128 |
color: var(--brand);
|
| 129 |
}
|
| 130 |
|
|
@@ -197,7 +205,7 @@ h1 {
|
|
| 197 |
|
| 198 |
.post-content h2 {
|
| 199 |
margin: 12px 0 10px;
|
| 200 |
-
font-size: clamp(1.
|
| 201 |
}
|
| 202 |
|
| 203 |
.post-content h2 a:hover {
|
|
|
|
| 53 |
display: flex;
|
| 54 |
align-items: center;
|
| 55 |
gap: 22px;
|
| 56 |
+
width: fit-content;
|
| 57 |
+
padding: 14px 22px;
|
| 58 |
+
border-radius: 16px;
|
| 59 |
+
background: linear-gradient(135deg, #111827 0%, #1e293b 55%, #263b67 100%);
|
| 60 |
+
box-shadow: 0 10px 24px rgba(30, 41, 59, 0.16);
|
| 61 |
}
|
| 62 |
|
| 63 |
.site-logo {
|
|
|
|
| 72 |
display: none;
|
| 73 |
font-size: 1.6rem;
|
| 74 |
letter-spacing: -0.04em;
|
| 75 |
+
color: #ffffff;
|
| 76 |
}
|
| 77 |
|
| 78 |
h1,
|
|
|
|
| 85 |
h1 {
|
| 86 |
margin: 0;
|
| 87 |
font-size: clamp(2.4rem, 6vw, 4rem);
|
| 88 |
+
color: #ffffff;
|
| 89 |
}
|
| 90 |
|
| 91 |
.brand-tagline {
|
|
|
|
| 120 |
}
|
| 121 |
|
| 122 |
.filter-button {
|
| 123 |
+
padding: 6px 10px;
|
| 124 |
+
border: 1px solid #dbe7fb;
|
| 125 |
+
border-radius: 8px;
|
| 126 |
+
background: #f4f8ff;
|
| 127 |
color: var(--muted);
|
| 128 |
+
font-size: 13px;
|
| 129 |
cursor: pointer;
|
| 130 |
}
|
| 131 |
|
| 132 |
.filter-button:hover,
|
| 133 |
.filter-button.is-active {
|
| 134 |
+
border-color: #b9c9f7;
|
| 135 |
+
background: #eaf1ff;
|
| 136 |
color: var(--brand);
|
| 137 |
}
|
| 138 |
|
|
|
|
| 205 |
|
| 206 |
.post-content h2 {
|
| 207 |
margin: 12px 0 10px;
|
| 208 |
+
font-size: clamp(1.05rem, 1.8vw, 1.32rem);
|
| 209 |
}
|
| 210 |
|
| 211 |
.post-content h2 a:hover {
|