kawapress/client #

Composables and components for code that runs in the browser and while pages are rendered on the server: themes, Runtime Plugins and Vue components used in Markdown.

Routing #

  • RouterLink — A link to another page of the site, rendered as a plain <a> with the site base applied. Clicks are handled by the global link interceptor, so a page with a thousand sidebar links does no per-link work: the only thing this component computes is whether it is the current page.
  • RouterView — Renders the current page, or the not-found page for a route the page table does not know. Nothing is rendered while the first page is still loading; the app mounts only after that, so a reader never sees an empty frame.
  • useRoute — Current route of the app, updated by every navigation.
  • useRouter — Router of the current app: navigation, guards and the current route.

Client #

  • Appearance — The appearance of the current page.
  • ClientOnly — Renders its default slot only after the browser has mounted the app. Server rendering and the first client render both produce an empty node, which keeps browser-only components from causing a hydration mismatch.
  • KawaOutlet — Renders an outlet: the theme's own content with the items plugins placed before and after it.
  • LocaleContext — The language of the current page and the other languages the visitor can switch to.
  • PLATFORM_DETECTION_SCRIPT — Inline script that marks <html data-kawa-platform> as apple or control before the first paint. Its content never changes, so every page can carry the same tag.
  • useAppearance — Follows the dark/light class on <html>, falling back to the operating system preference when neither class is present. Themes only need to toggle that class; components do not depend on a particular theme implementation.
  • useLocale — The locale of the current route, and the links to the same page in every locale.
  • usePageData — The data of the current page, or undefined for a route without a page.
  • usePlatformAttribute — Puts the platform detection script into the page head, so CSS can show ⌘ or Ctrl from the first frame: static HTML cannot know the visitor's platform, and swapping the text after hydration makes the layout jump.
  • useSite — The site data of the current route: title, base and theme config with the current locale applied.
  • useThemeConfig — The theme config of the current route, with the locale's values over the site's.

Functions #

  • resolveLocaleIndex — Finds the locale key a route path belongs to. root owns every path outside the other locale prefixes; the longest matching prefix wins.
  • withBase — Prefixes a site path with the site base. External URLs and # anchors are returned as they are.
  • withoutBase — Takes the site base off a path, or returns undefined when the path is not under it.

Types #

  • OutletItem — A collected outlet item. id and owner are filled in by KawaPress.
  • OutletName — Name of an outlet; one of OUTLET_NAMES.
  • OutletRegistry — Outlet items grouped by outlet name. Each side is in plugin install order.
  • Route — The route the app currently shows. A documentation site only needs a lookup from a path to a page, so the route is plain data: no matcher, no params, no nested records.
  • RouteGuard — Runs before a navigation commits. Returning false cancels it; returning nothing (or true) lets it through. There is no redirect: a guard that wants another URL calls router.push() itself.
  • RouteHook — Runs after a navigation committed.
  • Router — Navigation API of a KawaPress site, a small subset of Vue Router's.

Variables #

  • OUTLET_NAMES — Every outlet a theme can render. The list is the public contract between plugins (which contribute interface pieces) and themes (which draw the default content of each outlet).

Comments