ZH
测试版翻译

@core / kit-landing

1.0.1 ▾
已验证MIT
GitHub

Next.js 落地页套件:区块页面、线索表单、Cookie 横幅和需同意的转化像素

代码14 个文件上下文约 910 个 token扫描通过

应用 .genpmignore 后将被注入的确切目录树。固定于

src/app/(landing)/_blocks/countdown.tsx只读 · f730e59
// "Contador real": solo con una fecha de fin verdadera; al pasar la fecha el bloque desaparece (nunca se reinicia).
import { z } from 'zod';
import { defineBlock, Section } from '@/lib/blocks';

const parts = (ms: number) => {
  const d = Math.floor(ms / 86_400_000);
  const h = Math.floor((ms % 86_400_000) / 3_600_000);
  const m = Math.floor((ms % 3_600_000) / 60_000);
  return d > 0 ? `${d} days ${h} hours` : h > 0 ? `${h} hours ${m} minutes` : `${Math.max(m, 1)} minutes`;
};

export const countdown = defineBlock({
  type: 'countdown',
  label: 'Countdown (real deadline)',
  icon: 'clock',
  schema: z.object({
    title: z.string().trim().min(1).max(160),
    endsAt: z.coerce.date(),
    /** Qué termina de verdad (condiciones visibles). */
    terms: z.string().trim().min(1).max(300),
  }),
  fields: [
    { name: 'title', label: 'Title (e.g. "Launch price ends in")', type: 'text', required: true },
    { name: 'endsAt', label: 'Real end date and time', type: 'datetime', required: true, help: 'Must be the real end of the offer. Fake or resetting deadlines are illegal (EU Directive 2005/29/EC).' },
    { name: 'terms', label: 'What ends (shown to visitors)', type: 'text', required: true },
  ],
  defaults: () => ({ title: 'Offer ends in', terms: '' }),
  Component: ({ data, ctx }) => {
    const left = data.endsAt.getTime() - Date.now();
    if (left <= 0) return null;
    return (
      <Section id={ctx.id} block="countdown" title={data.title} ctx={ctx}>
        <p className="blk-countdown__time">
          <time dateTime={data.endsAt.toISOString()}>{parts(left)}</time>
        </p>
        <p className="blk__note">
          {data.terms} Ends {data.endsAt.toISOString().slice(0, 16).replace('T', ' ')} UTC.
        </p>
      </Section>
    );
  },
});

举报 @core/kit-landing

使用 GitHub 登录后才能举报包。