100 lines
1.9 KiB
Vue
100 lines
1.9 KiB
Vue
|
|
<template>
|
||
|
|
<div>
|
||
|
|
<NavMenu />
|
||
|
|
<div class="news-container">
|
||
|
|
<!-- 新闻标题 -->
|
||
|
|
<h2 class="news-title">新闻资讯</h2>
|
||
|
|
<p class="news-subtitle">New Voices in the Cloud, Intelligence at the Frontier.</p>
|
||
|
|
|
||
|
|
<!-- 新闻列表 -->
|
||
|
|
<ul class="news-list">
|
||
|
|
<li v-for="news in newsList" :key="news.slug" class="news-item">
|
||
|
|
<div class="news-date">{{ news.category }}</div>
|
||
|
|
<nuxt-link class="news-link" :to="'/news/' + news.slug">{{ news.title }}</nuxt-link>
|
||
|
|
</li>
|
||
|
|
</ul>
|
||
|
|
</div>
|
||
|
|
<FooterMenu />
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import NavMenu from "../../components/NavMenu.vue";
|
||
|
|
import FooterMenu from "../../components/FooterMenu.vue";
|
||
|
|
export default {
|
||
|
|
components: { NavMenu, FooterMenu },
|
||
|
|
async asyncData({ $content }) {
|
||
|
|
try {
|
||
|
|
// 直接读取 `static/news/*.md` 目录下的所有文章
|
||
|
|
const newsList = await $content().sortBy("order", "asc").fetch();
|
||
|
|
return { newsList };
|
||
|
|
} catch (error) {
|
||
|
|
console.error("Error fetching news:", error);
|
||
|
|
return { newsList: [] };
|
||
|
|
}
|
||
|
|
},
|
||
|
|
};
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
/* 容器 */
|
||
|
|
.news-container {
|
||
|
|
max-width: 900px;
|
||
|
|
margin: 0 auto;
|
||
|
|
padding: 40px 20px;
|
||
|
|
text-align: center;
|
||
|
|
min-height: 50vh;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 标题 */
|
||
|
|
.news-title {
|
||
|
|
font-size: 28px;
|
||
|
|
color: #ff6702;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 副标题 */
|
||
|
|
.news-subtitle {
|
||
|
|
font-size: 14px;
|
||
|
|
color: #777;
|
||
|
|
margin-bottom: 5rem;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 新闻列表 */
|
||
|
|
.news-list {
|
||
|
|
list-style: none;
|
||
|
|
padding: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 新闻项 */
|
||
|
|
.news-item {
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
padding: 12px 0;
|
||
|
|
border-bottom: 1px solid #ddd;
|
||
|
|
height: 4rem;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 日期样式 */
|
||
|
|
.news-date {
|
||
|
|
font-size: 14px;
|
||
|
|
color: #ff6702;
|
||
|
|
width: 150px;
|
||
|
|
text-align: left;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 新闻链接 */
|
||
|
|
.news-link{
|
||
|
|
font-size: 16px;
|
||
|
|
color: #333;
|
||
|
|
text-decoration: none;
|
||
|
|
transition: color 0.3s;
|
||
|
|
}
|
||
|
|
|
||
|
|
/* 悬停时变橙色 */
|
||
|
|
.news-link:hover {
|
||
|
|
color: #ff6702;
|
||
|
|
}
|
||
|
|
</style>
|