lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.76k stars 74 forks source link

search.pages() return results is zero #612

Closed XIPEGM closed 1 month ago

XIPEGM commented 1 month ago

Version

v2.2

Platform

Win10

What steps will reproduce the bug?

我根据官方的 Simple Blog 模板,简化写了一个类似的Theme插件,部署在deno.land/x,如果我的 markdown file 放在本地磁盘,它会工作良好,但是如果我的数据是放在supabase,比如:

import { Orm } from "jsr:@xtool/mod";

const db = new Orm({
  user: Deno.env.get("SUPABASE_USER"),
  password: Deno.env.get("SUPABASE_PASSWORD"),
  hostname: Deno.env.get("SUPABASE_HOSTNAME"),
  CERT: Deno.env.get("SUPABASE_CERT"),
});

const res = await db.select().table("posts");
export default function* () {
  for (const article of res.rows) {
    article.date = article.created_at;  // Lume default use date property
    yield {
      type: "post",
      layout: "post.vto",
      origin: "supabase",
      url: `/posts/${article.title}/`,
      ...article
    };
  }
}

动态生成的页面,那么 Theme 中的 archive.page.js 中, search.pages("", "date=desc") 中返回为0.

How often does it reproduce? Is there a required condition?

every time

What is the expected behavior?

xxx.page.js 应该控制一下调用的顺序,防止 pages 没有正确装载。

What do you see instead?

output 0

Additional information

nothing

oscarotero commented 1 month ago

I suspect this is caused by the render order.

Can use the renderOrder variable to make sure the pages are generated before the pagination. Take a look to this: https://lume.land/docs/core/render-order/

XIPEGM commented 1 month ago

I suspect this is caused by the render order.

Can use the renderOrder variable to make sure the pages are generated before the pagination. Take a look to this: https://lume.land/docs/core/render-order/

Thank you! It was my carelessness that caused it。

Suggest placing the link render-order at the bottom of the page multiple-pages