import { ANCHOR_PREFIX } from "#configuration/constants/document.constants"; import { HOME_PAGE } from "#core/ids/page.ids"; export const HOME_PATH = "/"; const QUERY_MARK = "?"; const pathOnly = function pathOnly(href: string): string { const stops = [href.indexOf(QUERY_MARK), href.indexOf(ANCHOR_PREFIX)].filter((at) => at !== -1); return stops.length === 0 ? href : href.slice(0, Math.min(...stops)); }; const segmentsOf = function segmentsOf(pathname: string): string[] { return pathOnly(pathname) .split(HOME_PATH) .filter((segment) => segment.length > 0); }; export const pagePath = function pagePath(page: string): string { return page === HOME_PAGE ? HOME_PATH : HOME_PATH + page; }; export const pageFromPath = function pageFromPath(pathname: string, home: string): string { const [page] = segmentsOf(pathname); return page ?? home; }; export const tabFromPath = function tabFromPath(pathname: string): string | null { const [, tab] = segmentsOf(pathname); return tab ?? null; }; export const tabLink = function tabLink(page: string, tab: string, section?: string): string { const base = `${pagePath(page)}${HOME_PATH}${tab}`; return section === undefined ? base : base + ANCHOR_PREFIX + section; }; export const tabPath = function tabPath(page: string, tabs: readonly { readonly id: string }[], tab: string): string { return tab === tabs[0]?.id ? pagePath(page) : tabLink(page, tab); }; const JSON_ROUTE = "/json/"; export const payloadPath = function payloadPath(page: string, tab: string | null = null): string { return tab === null ? JSON_ROUTE + page : JSON_ROUTE + page + HOME_PATH + tab; }; export const SITE_URL = "https://banes-lab.com"; export const AUTHOR_ADDRESS = "jay@banes-lab.com"; export const AUTHOR_MAIL = `mailto:${AUTHOR_ADDRESS}`; export const CONTACT_MAIL = "contact@banes-lab.com"; export const AUTHOR_PROFILE = "https://linkedin.com/in/jay-baleine"; export const AUTHOR_DISCORD = "https://discord.com/users/406828985696387081"; export const AUTHOR_GITHUB = "https://github.com/Varietyz"; export const METHODOLOGY_REPOSITORY = "https://github.com/Varietyz/Disciplined-AI-Software-Development"; const LICENSE_ROOT = "/assets/licenses/pag/"; export const LICENSE_FILE = `${LICENSE_ROOT}LICENSE`; export const LICENSE_HEADER_FILE = `${LICENSE_ROOT}license-header.txt`; export const LICENSE_INQUIRY_MAIL = `${AUTHOR_MAIL}?subject=PAG Commercial License Inquiry`; export const GRAMMAR_REPOSITORY = "https://github.com/Varietyz/pag-lang"; export const CREATIVE_COMMONS = "https://creativecommons.org/licenses/by-sa/4.0/";