PT

@core / seo

1.0.0 ▾
verificadoMIT
GitHub

SEO para sites GenPM: metadados com canônica e hreflang, sitemaps em partes, robots.txt, llms.txt e JSON-LD seguro

Código9 arquivosContexto~639 tokensanálise aprovada

A árvore exata que será injetada, após o .genpmignore. Fixada em

src/lib/seo/url.tssomente leitura · 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();
}

Denunciar @core/seo

Entre com o GitHub para denunciar um pacote.