Skip to content

Incremental engine for long horizon agents 🌟 Star if you like it!

3.7 KB
Raw Blame
export const SITE_URL = 'https://cocoindex.io';
export const GITHUB_REPO = 'https://github.com/cocoindex-io/cocoindex';
// Branded 1200Γ—630 social cards. Hosted in the `blobs` image repo
// (cocoindex.io/blobs/) so they're live independent of the marketing/docs
// deploy cadence; generated by scripts/og/{docs,examples}.tsx in the homepage
// repo, then committed to blobs. Social platforms (X, LinkedIn, Slack) don't
// render SVG, so og:image points at these rasters.
export const OG_IMAGE_DOCS = `${SITE_URL}/blobs/og/docs.png`;
export const OG_IMAGE_EXAMPLES = `${SITE_URL}/blobs/og/examples.png`;
export const OG_IMAGE_WIDTH = '1200';
export const OG_IMAGE_HEIGHT = '630';
export const OG_IMAGE_DOCS_ALT = 'CocoIndex docs β€” build incremental data pipelines for AI';
export const OG_IMAGE_EXAMPLES_ALT = 'CocoIndex examples β€” real pipelines you can clone and run';
export const DISCORD_URL = 'https://discord.com/invite/zpA9S2DR7s';
export const SITE_MAIN = 'https://cocoindex.io';
export const SITE_BLOG = 'https://cocoindex.io/blogs';
// `import.meta.env.BASE_URL` reflects `base` in astro.config.mjs (e.g. `/docs-v0/`).
// DOCS_BASE and the URL builders below are the single source for the /docs base
// and the trailingSlash: 'always' convention β€” don't rebuild them per file.
export const DOCS_BASE = import.meta.env.BASE_URL.replace(/\/$/, '');
export const SITE_EXAMPLES = `${DOCS_BASE}/examples/`;
export const pageUrl = (slug: string) => new URL(`${DOCS_BASE}/${slug}/`, SITE_URL).toString();
export const pageMarkdownUrl = (slug: string) => new URL(`${DOCS_BASE}/${slug}.md`, SITE_URL).toString();
export const LLMS_TXT_URL = new URL(`${DOCS_BASE}/llms.txt`, SITE_URL).toString();
export const LLMS_FULL_TXT_URL = new URL(`${DOCS_BASE}/llms-full.txt`, SITE_URL).toString();
export const SKILL_MD_URL = new URL(`${DOCS_BASE}/skill.md`, SITE_URL).toString();
// GitHub web-editor URL prefix for the "Edit this page" link.
export const DOCS_EDIT_BASE = 'https://github.com/cocoindex-io/cocoindex/edit/main/docs';

// A content-collection id for `sources/index.md` is `sources/index`; the URL
// slug we want is just `sources`. Mirrors the blog-site helper pattern.
export const docSlug = (id: string) => id.replace(/\/index$/, '');

// Titles can mark 1–2 words with *asterisks* to italicize them in coral,
// matching the design mock: `Build your first flow in *10 minutes.*`.
// titleText strips the markers for metadata; titleMarkup emits safe HTML.
const HTML_ESCAPES: Record<string, string> = {
  '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;',
};
const escapeHtml = (s: string) => s.replace(/[&<>"']/g, (c) => HTML_ESCAPES[c]);

export const titleText = (s: string): string => s.replace(/\*([^*]+)\*/g, '$1');

// Display title for a docs entry with the slug as fallback β€” guards both
// missing and empty-string titles so HTML pages and their .md twins agree.
export const docTitle = (id: string, title: unknown): string =>
  titleText(typeof title === 'string' && title.length > 0 ? title : docSlug(id));

export const titleMarkup = (s: string): string =>
  s.replace(/\*([^*]+)\*|([^*]+)/g, (_m, em, rest) =>
    em ? `<em>${escapeHtml(em)}</em>` : escapeHtml(rest),
  );

export const POSTHOG_KEY = (import.meta.env.COCOINDEX_DOCS_POSTHOG_API_KEY ?? '') as string;
export const POSTHOG_HOST = 'https://us.i.posthog.com';
export const MIXPANEL_TOKEN = (import.meta.env.COCOINDEX_DOCS_MIXPANEL_API_KEY ?? '') as string;

export const SCARF_PIXEL_ID = (import.meta.env.COCOINDEX_DOCS_SCARF_PIXEL_ID ?? '') as string;
export const SCARF_QUICKSTART_PIXEL_ID = (import.meta.env.COCOINDEX_DOCS_SCARF_QUICKSTART_PIXEL_ID ?? '') as string;

// Brand paper as plain hex for <meta name="theme-color"> (CSS vars can't reach meta tags).
export const THEME_COLOR = '#0A0A0A';