import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; /** * The homepage is a UXFront page with its own title and description, and it * keeps every link main's homepage had, the site's chrome links, and its code * samples highlighted in the HTML. Unknown routes get the static host's * 404.html. * * Requires a prior build, like og-images.build.test.ts. */ const OUTPUT = fileURLToPath(new URL("../.output/public", import.meta.url)); const read = (file: string) => readFileSync(join(OUTPUT, file), "utf8"); // The homepage's title and description, as rendered. const TITLE = "Type-safe Styling Engine for the AI Era - styleframe"; const DESCRIPTION = "Styleframe is the type-safe styling engine for the AI era. Author tokens, themes, utilities and recipes in TypeScript, and ship zero-runtime CSS."; // The calls to action, in order: the hero's, one per chapter that had one on // main (the fluid-design docs page replaces its demo), and the finale's. // GitHub is at the repository's current home. const CALLS_TO_ACTION = [ "/docs/getting-started/introduction", "https://github.com/uxfront-com/styleframe", "/docs/theme/design-tokens", "/docs/api/themes", "/docs/api/recipes", "/scanner", "/figma", "/docs/theme/design-tokens/fluid-design", "/docs/getting-started/introduction", "https://github.com/uxfront-com/styleframe", ]; // Where the two actions sit in the calls to action. const ACTIONS = { hero: [0, 2], finale: [-2, undefined] } as const; // The start of UxStarIcon's path. const STAR_ICON = 'd="M8 .25a.75.75'; // app.vue's rule that removes the arrow from the kit's linked cards, as the // build writes it. const NO_CARD_ARROW = /\.ux-traits \.ux-traits__linked \.ux-traits__link strong::?after\{content:none\}/; // The features that linked somewhere on main: the config section's strip, and // the one in a chapter's UxTraits. const STRIP_LINKS = [ "/docs/api", "/docs/api/composables", "/docs/api/themes", "/docs/getting-started/installation", "/docs/api/instance#configuration-options", "/docs/getting-started/guides", ]; const TRAIT_LINKS = ["/docs/api/recipes"]; const LOGIN_URL = "https://app.styleframe.dev"; // What the docs chrome links (its header, footer and table of contents), plus // the site footer's Log in. const CHROME_LINKS = [ "/docs/getting-started/introduction", "/changelog", LOGIN_URL, "https://github.com/uxfront-com/styleframe", "https://x.com/styleframe_dev", "https://discord.com/invite/KCVwuGz44M", "https://storybook.styleframe.dev", "https://play.styleframe.dev", "/privacy", "/terms", "/license", ]; describe("homepage", () => { const html = existsSync(join(OUTPUT, "index.html")) ? read("index.html") : ""; const head = html.match(/
/)?.[0] ?? ""; // The page's own content: