Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import { slug as githubSlug } from 'github-slugger';
// Docs files and directories may carry a numeric sorting prefix such as `04.Image Generation` or
// `01.projects.mdx`. The prefix orders the autogenerated sidebar and never appears in URLs or labels.
// Plain JavaScript so Node scripts can share it with the site.
const sortPrefixRegEx = /^(\d+)\./;
/**
* The numeric sorting prefix of a path segment, or undefined when it has none.
* @param {string} segment
* @returns {number | undefined}
*/
export const getSortPrefix = (segment) => {
const match = sortPrefixRegEx.exec(segment);
return match ? Number(match[1]) : undefined;
};
/** @param {string} segment */
export const stripSortPrefix = (segment) => segment.replace(sortPrefixRegEx, '');
/**
* Astro's default docs entry id with sorting prefixes removed: a frontmatter `slug` wins, otherwise
* each path segment is slugified and a trailing `/index` is dropped.
* @param {{ entry: string; data: Record<string, unknown> }} options
* @returns {string}
*/
export const generateDocsId = ({ entry, data }) => {
// Truthiness, as in Astro's default: an empty slug falls back to the path.
if (data.slug) return String(data.slug);
return entry
.replace(/\.[^./]+$/, '')
.split('/')
.map((segment) => githubSlug(stripSortPrefix(segment)))
.join('/')
.replace(/\/index$/, '');
};