Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

1.2 KB
Raw Blame
/**
 * Base for documentation links surfaced in the dashboard.
 *
 * Kept in one place so a docs restructure, a domain change or a locale prefix
 * is a single edit rather than a sweep through every table and settings page.
 */
export const DOCS_BASE_URL = 'https://spreecommerce.org/docs'

/**
 * The other two destinations the account menu offers, kept here for the same
 * reason as the docs base: one edit if a domain moves.
 */
export const COMMUNITY_URL = 'https://discord.spreecommerce.org'
export const CONTACT_URL = 'https://spreecommerce.org/contact'

/**
 * Resolves a documentation path to a full URL.
 *
 * A bare path is taken as relative to the user guide, which is where the
 * merchant-facing pages live; an absolute URL is returned untouched, so a
 * plugin can point at its own documentation.
 *
 * @param path - `'catalogs'`, `'developer/providers/erp'`, or a full URL
 * @returns the URL to link to
 */
export function docsUrl(path: string): string {
  if (/^https?:\/\//.test(path)) return path

  const trimmed = path.replace(/^\/+/, '')
  const section = /^(user|developer)\//.test(trimmed) ? trimmed : `user/${trimmed}`
  return `${DOCS_BASE_URL}/${section}`
}