Reference › Project
clarusjs 0.8.0
All releases · [email protected] on npm
Minor Changes
- Focus and announcements on navigation. After a fragment swap or a client route render, focus moves to the new content: the
#hashtarget, else the page's<h1>, else<main>. The new title is announced in a polite live region. The router and the navigation script stay within their 1 KB budgets: the work is in the loader. #151 - Every page's
<head>: -head: { titleTemplate, tags, jsonLd }in the plugin.titleTemplate(%s · Site) wraps each title, client routes included.tags([tag, attrs, content?]) go on every page, for example icons, theme colour or analytics scripts such as gtag.jsonLdis site-wide schema.org data. -<cl-head>…</cl-head>anywhere in a page adds tags to its<head>. They win over site tags with the same key (title, meta name/property, canonical…), and a<title>there is used as written. -transformHead(head, page)exported fromsrc/head.tsruns last on every page. - JSON-LD in templates:<script type="application/ld+json">{{ { "@type": "Article", headline: title } }}</script>writes the value as JSON that is safe inside the script. #144 - Components from packages:
@import x from 'some-package/x.tscl'works like a component insrc/. clarusjs follows@importlines into packages, so their islands get client chunks and their scoped styles are bundled, in dev and build. Packages that ship.tsclfiles are bundled for server rendering. #162 robots.txtand a 404 page. - Withsiteset,vite buildwritesrobots.txtthat allows all crawlers and points at the sitemap. Apublic/robots.txtof your own wins, androbots: falseturns it off. -src/pages/404.tscl(or404.md) is served for unknown addresses with status 404 in dev, in server mode and invite preview. -vite buildwrites it to404.htmlfor static hosts. Its relative links are resolved from the site root, so they work at any depth, and it is never in the sitemap. #149- Sitemap exclusions:
sitemap: { exclude: ["/drafts/", "/tags/*", "/legal"] }leaves pages out by path (*is one segment,any depth). A page leaves itself out with<cl-head><meta name="sitemap" content="false"></cl-head>, and the marker is removed from the built page. #148 - Sitemap: with
siteset,vite buildwritessitemap.xmllisting every prerendered static page. Client and server routes, data files, fragments andnoindexpages are left out. Each page'slastmodis its source file's last commit, read with one batchedgit log. Files git doesn't know useSOURCE_DATE_EPOCH, or get no date.sitemap: falseturns it off. #148 - Canonical URLs and social cards: with
site: { url, name?, image? }, every page gets<link rel="canonical">and Open Graph/Twitter tags (title without the template, description, url, type, site name, image as an absolute URL, card type). They fill in like site tags, so a page's own tags win. Withoutsite, a relativeog:imageorog:urlfails the build instead of shipping a broken card. Link checking also checks absolute links to the site itself. The published JavaScript no longer carries source comments (the declarations and the browser runtime keep theirs), which keeps the package small. #147 - Tailwind CSS v4 works with its official Vite plugin, with no extra setup. Component
<style>blocks can start with@reference(for@apply) or@import. Those statements are kept outside the component's@scopeblock, and their relative paths still resolve from the component file. #155
Patch Changes
gitDates(root, dir)is exported fromclarusjs/vite: the newest commit time of every file under a folder, from onegit log(the sitemap's dates), for themes and plugins. #165- Fragment navigation no longer turns a page's own
history.pushState/replaceStateinto a page load (it refetched the fragment and moved focus). Back and forward still swap pages, and areplaceStatethat interrupts a page still loading shows that page. #168