From 32e328bbf9ac528855101fb74af13ce6d3ff6633 Mon Sep 17 00:00:00 2001 From: toom1996 Date: Mon, 11 Aug 2025 16:55:16 +0800 Subject: [PATCH] update --- src/components/GuessYouLike.astro | 159 ++++++++++++++++++++++++++++++ src/pages/index.astro | 108 ++++++++++++++------ src/pages/news.astro | 42 +------- src/pages/news/[...slug].astro | 5 +- 4 files changed, 243 insertions(+), 71 deletions(-) create mode 100644 src/components/GuessYouLike.astro diff --git a/src/components/GuessYouLike.astro b/src/components/GuessYouLike.astro new file mode 100644 index 0000000..91f2c27 --- /dev/null +++ b/src/components/GuessYouLike.astro @@ -0,0 +1,159 @@ +--- +import { Image } from "astro:assets"; +const {data} = Astro.props +--- +
+
+

猜你喜欢

+
    + { + data?.map((item, index) => { + return ( +
  • +
    + + {item.title} + +
    +
    +

    + + {item.title} + +

    + {item.created_at} +
    +
  • + ); + }) + } +
+
+
+ \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index e8b6ab5..882cf2d 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,8 +4,7 @@ import { getConfig } from "../../utils/config"; import { newsIndex } from "../../utils/rpc"; import { Image } from "astro:assets"; const config = getConfig(Astro); -const { code, data, guess } = await newsIndex(config.id, 3, 1); -console.log(data) +const { code, data, guess } = await newsIndex(config.id, 20, 1); --- @@ -215,40 +214,89 @@ console.log(data)
-
-

最新资讯

+
+

最新资讯

+

+ 霍尔果斯飞驰广告有限公司专注于提供从基础到进阶的SEO优化策略、广告投放方案、内容运营实战技巧以及网站转化率提升解决方案。同时,我们也持续分享最新的科技动态、财经洞察、软件评测等多类型优质资讯,助力用户在数字时代高效获取价值信息。 +

- { - data.map((item) => { - return ( -
-
- -
- {item.title} +
+
+
+ + { + data?.slice(2, 3).map((e, index) => ( + -
- {item.created_at} -
-

- {item.title} -

+ )) + } +
+ +
- ); - }) - } +
+
+ { + data?.slice(18, 20).map((e, index) => ( + + )) + } + { + guess?.slice(0, 9).map((e, index) => ( + + )) + } +
+
+
+
diff --git a/src/pages/news.astro b/src/pages/news.astro index d3c6b78..9781e55 100644 --- a/src/pages/news.astro +++ b/src/pages/news.astro @@ -13,6 +13,7 @@ import { newsIndex } from "../../utils/rpc"; import { Image } from "astro:assets"; import PaginationComponent from "../components/Pagination.astro"; import BreadComponent from "../components/Breadcrumb.astro"; +import GuessYouLike from "../components/GuessYouLike.astro"; const config = getConfig(Astro); // 每页显示多少条 @@ -157,46 +158,7 @@ if (data.length == 0 || code !== 0) {
-
-
-

猜你喜欢

-
    - { - guess?.map((item, index) => { - return ( -
  • -
    - - {item.title} - -
    -
    -

    - - {item.title} - -

    - {item.created_at} -
    -
  • - ); - }) - } -
-
-
+
diff --git a/src/pages/news/[...slug].astro b/src/pages/news/[...slug].astro index c9da0eb..c37c402 100644 --- a/src/pages/news/[...slug].astro +++ b/src/pages/news/[...slug].astro @@ -3,6 +3,7 @@ import Layout from "../../layouts/Layout.astro"; import { getConfig } from "../../../utils/config"; import { newsDetail, columns as getColumns } from "../../../utils/rpc"; import Breadcrumb from "../../components/Breadcrumb.astro"; +import GuessYouLike from "../../components/GuessYouLike.astro"; import { formatDate } from "../../../utils/date"; const { slug } = Astro.params; const config = getConfig(Astro); @@ -39,7 +40,8 @@ if (!slug) { return Astro.rewrite("/404"); } -var { code, data } = await newsDetail(slug, config); +var { code, data, guess } = await newsDetail(slug, config); +console.log(guess) if (!data || code !== 0) { return Astro.rewrite("/404"); } @@ -142,6 +144,7 @@ const bytedanceData = formatDate(data.created_at) }
+