Skip to content

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.

1.9 KB
Raw Blame
---
import '@astrojs/starlight/style/markdown.css';

import { localizeHtmlLinks } from '../locale-links.mjs';

// On a locale's routes, links into the docs stay in that locale, also on pages that show the English content.
const { locale } = Astro.locals.starlightRoute;
const localizedHtml =
  locale && localizeHtmlLinks(await Astro.slots.render('default'), { base: import.meta.env.BASE_URL, locale });
---

{/* Starlight's own markup, plus the name the script below gives a table that has none. */}
<div class="sl-markdown-content" data-table-label={Astro.locals.t('markdown.tableLabel')}>
  {localizedHtml ? <Fragment set:html={localizedHtml} /> : <slot />}
</div>

<script>
  // A table wider than the content column scrolls in its wrapper (`plugins/rehype-table-scroll.mjs`). Make that wrapper
  // a named, focusable region so it can be scrolled from the keyboard, as Safari does not focus scroll boxes; tables
  // that fit stay out of the tab order.
  const sync = (wrapper: HTMLElement) => {
    if (wrapper.scrollWidth > wrapper.clientWidth) {
      wrapper.tabIndex = 0;
      wrapper.setAttribute('role', 'region');
      const content = wrapper.closest<HTMLElement>('[data-table-label]')!;
      wrapper.setAttribute('aria-label', wrapper.dataset.label || content.dataset.tableLabel!);
    } else {
      wrapper.removeAttribute('tabindex');
      wrapper.removeAttribute('role');
      wrapper.removeAttribute('aria-label');
    }
  };
  const wrappers = [...document.querySelectorAll<HTMLElement>('.table-scroll')];
  // Watch the table too: it can widen (a web font swapping in) without its wrapper changing size.
  const observer = new ResizeObserver((entries) => {
    for (const entry of entries) sync(entry.target.closest<HTMLElement>('.table-scroll')!);
  });
  for (const wrapper of wrappers) {
    observer.observe(wrapper);
    const table = wrapper.querySelector('table');
    if (table) observer.observe(table);
  }
</script>