ZH
测试版翻译

@core / seo

1.0.0 ▾
已验证MIT
GitHub

GenPM 站点 SEO:带 canonical 和 hreflang 的元数据、分片站点地图、robots.txt、llms.txt 和安全的 JSON-LD

代码9 个文件上下文约 639 个 token扫描通过

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

src/lib/seo/url.ts只读 · cf4e3c3
// URLs absolutas a partir de SITE_URL.

export function siteUrl(env: Record<string, string | undefined> = process.env): URL {
  const raw = env.SITE_URL;
  if (!raw) throw new Error('SITE_URL is not set (see .env.example)');
  const u = new URL(raw);
  if (u.protocol !== 'https:' && u.hostname !== 'localhost') throw new Error('SITE_URL must use https');
  return u;
}

/** `/blog/x` → `https://example.com/blog/x`; las URLs absolutas se devuelven tal cual. */
export function absoluteUrl(pathOrUrl: string, base: URL = siteUrl()): string {
  return /^https?:\/\//.test(pathOrUrl) ? pathOrUrl : new URL(pathOrUrl, base).toString();
}

举报 @core/seo

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