@uxfront/layer-ui
v0.1.11
Published
Nuxt layer for the uxfront.com family of homepages: registers @uxfront/ui, self-hosts its fonts, adds useUxHead() and keeps the first paint free of scripts and web fonts.
Maintainers
Readme
@uxfront/layer-ui
The Nuxt layer for the uxfront.com family of homepages. Extend it to build a homepage with the same look, feel and Lighthouse scores as uxfront.com, from the @uxfront/ui components and the @uxfront/scene formations.
Install
pnpm add @uxfront/layer-ui @uxfront/scene// nuxt.config.ts
export default defineNuxtConfig({
extends: ["@uxfront/layer-ui"],
runtimeConfig: { public: { siteUrl: "https://inkline.io" } },
});Then build the page from Ux* components (see the @uxfront/ui README or uxfront.com's homepage), and give it a head:
useUxHead({
title: "Inkline: the UI library for every framework",
description: "Perfectly designed components, in all seven frameworks.",
siteName: "Inkline",
image: { path: "/og.jpg", width: 1200, height: 630, alt: "…" },
logo: "/apple-touch-icon.png",
sameAs: ["https://github.com/inkline"],
});What it adds
- Components and composables. Every
@uxfront/uicomponent (UxSite,UxHero,UxChapter, …) anduseExperience()are auto-imported, andv-scrambleis registered. Formations are imported explicitly from@uxfront/scene/formations. - Fonts. Geist, Geist Mono and Instrument Serif, self-hosted by
@nuxt/fontswith metric-matched fallbacks. useUxHead(options). Title (no title template), description, canonical URL, Open Graph and Twitter cards with their title, description and image alt text, Organization structured data, and the darktheme-colorandcolor-scheme. All of it applies to the calling page only.runtimeConfig.public.siteUrlis the origin it builds URLs on. TheOrganizationbelongs to the site, not the page: its@idis${siteUrl}/#organizationand itsurlthe site's root on every page, so your own structured data can point at it by@id. Passlogo, a path likeimage.path, to give it a logo.- A clean critical path. On pages that render
UxSiteorUxErrorPage, the first frame needs nothing but the prerendered HTML and its inline styles. Once the browser reports the first contentful paint, a small inline loader brings in the app bundle, the web fonts and every stylesheet the page links: the entry one, and the chunk ones a bigger app, like one with docs, splits off for its components. Lazy chunks are never prefetched, so they don't compete with those downloads: the scene's engine and shaders load once the page is idle, and the rest when the app first needs them.
Sharing an app
Apart from turning off chunk prefetching, the layer changes nothing outside those pages, so a homepage can live in the same app as docs or anything else:
- It ships no
app.vue,error.vue, global CSS, route rules or deployment settings. - The homepage's base styles only apply while a
UxSiteis on the page. - Other pages render as Nuxt normally renders them, except that no page prefetches lazy chunks. On a homepage, the app's global and chunk stylesheets still load, just after first paint, so client-side navigation to other pages keeps their styles. They also apply to the homepage then, so keep global CSS from restyling
.ux-site.
Site-wide settings stay in the app. uxfront.com's nuxt.config.ts has examples: security headers, immutable caching of /_nuxt/**, and static prerendering for Cloudflare.
