[求助] nuxt-og-image 自定义模板在 Cloudflare Pages 渲染超时

2 天前
 monway

各位大佬好,请教一个问题。

我的平台是一个学习网站,我希望用户在学习完后点击分享到 Twitter 中能够展示一个比较美观的缩略图卡片,提高点击率。

网站是用 Nuxt 编写的,刚好发现 nuxt-og-image 完全符合我的需求。我编写了一个模板,本地测试没问题。

我的网站是部署在 CloudFlare 的 Pages 中,我发现使用默认的模板可以正常渲染,但使用我自定义的模板访问 OG 图片就会提示超出 CPU 时间限制。

因此我升级了 CloudFlare ,使用付费版发现还是不行。

这是我的代码,感觉也不是很复杂

<template>
  <div
    style="
      width: 1200px;
      height: 630px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      background: linear-gradient(145deg, #ffffff 30%, #0ea5e9 100%);
      border-radius: 32px;
      font-family: sans-serif;
      color: #111827;
      position: relative;
      overflow: hidden;
      padding: 80px;
      text-align: center;
      box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    "
  >
    <p
      style="
        font-size: 32px;
        font-weight: 700;
        color: #0284c7;
        margin: 0 0 30px 0;
      "
    >
      🚀 xxxxxxxxx!
    </p>
    <h1
      style="
        font-size: 76px;
        font-weight: 900;
        margin: 0 0 25px 0;
        line-height: 1.2;
      "
    >
      xxxxxxxx
    </h1>

    <p
      style="
        font-size: 28px;
        font-weight: 600;
        color: #374151;
        margin: 0 0 35px 0;
        max-width: 900px;
        line-height: 1.3;
      "
    >
      xxxxxxxx
    </p>

    <p
      style="
        font-size: 36px;
        font-weight: 900;
        color: #0284c7;
        margin: 0 0 10px 0;
      "
    >
      Alice
    </p>
    <div
      style="
        width: 80px;
        height: 4px;
        background: #0284c7;
        border-radius: 2px;
        margin: 0 0 30px 0;
      "
    ></div>


    <p
      style="
        font-size: 24px;
        color: #374151;
        margin: 0 0 40px 0;
        font-weight: 500;
      "
    >
      xxxxxxx
    </p>

    <div
      style="
        position: absolute;
        right: 80px;
        bottom: 60px;
        font-size: 200px;
        color: rgba(16, 185, 129, 0.05);
      "
    >
      🏆
    </div>

    <div
      style="
        font-size: 20px;
        font-weight: 400; /* 普通字重 */
        color: #6b7280; /* 淡灰色 */
        position: absolute;
        bottom: 35px; /* 靠近底部 */
        text-align: center;
      "
    >
      Shared from xxxxxx
    </div>
  </div>
</template>

请教各位大佬,有没有比较简洁快速的解决方案。

250 次点击
所在节点    前端开发
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://ex.noerr.eu.org/t/1156413

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX