caps-sa 0.7.0

Cache-friendly, parallel, sample-sort-based suffix array construction (Rust port of CaPS-SA)
Documentation
---
import config from 'virtual:starlight/user-config';
import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
import Search from 'virtual:starlight/components/Search';
import SiteTitle from 'virtual:starlight/components/SiteTitle';
import SocialIcons from 'virtual:starlight/components/SocialIcons';
import ThemeToggle from './ThemeToggle.astro';

const shouldRenderSearch =
  config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro';

const REPO = 'COMBINE-lab/caps-sa';
const BASE = import.meta.env.BASE_URL.replace(/\/?$/, '/');

const navLinks = [
  { label: 'Quick start',  href: `${BASE}getting-started/quick-start/` },
  { label: 'Algorithm',    href: `${BASE}concepts/algorithm/` },
  { label: 'CLI',          href: `${BASE}reference/cli/` },
  { label: 'API',          href: `${BASE}reference/api/` },
];

// Resolve the latest GitHub release at build time. Cached on globalThis so a
// single build only hits the GitHub API once across all page renders.
type Release = { label: string; url: string };
const g = globalThis as { __capssaRelease?: Promise<Release> };
g.__capssaRelease ??= (async () => {
  const fallback: Release = { label: 'Releases', url: `https://github.com/${REPO}/releases` };
  try {
    const headers: Record<string, string> = { Accept: 'application/vnd.github+json' };
    if (process.env.GITHUB_TOKEN) headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
    const res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=1`, { headers });
    if (!res.ok) return fallback;
    const releases = (await res.json()) as Array<{ tag_name: string; html_url: string }>;
    if (!Array.isArray(releases) || releases.length === 0) return fallback;
    return { label: releases[0].tag_name, url: releases[0].html_url };
  } catch {
    return fallback;
  }
})();
const { label: versionLabel, url: versionUrl } = await g.__capssaRelease;
---

<div class="header capssa-header">
  <div class="title-wrapper sl-flex">
    <SiteTitle />
    <a class="version-pill sl-hidden md:sl-flex" href={versionUrl} aria-label={`Release notes for ${versionLabel}`}>{versionLabel}</a>
  </div>

  <nav class="top-nav sl-hidden md:sl-flex" aria-label="Primary">
    {navLinks.map(({ label, href }) => (
      <a href={href}>{label}</a>
    ))}
  </nav>

  <div class="sl-flex print:hidden search-cell">
    {shouldRenderSearch && <Search />}
  </div>

  <div class="sl-hidden md:sl-flex print:hidden right-group">
    <div class="sl-flex social-icons">
      <SocialIcons />
    </div>
    <ThemeToggle />
    <LanguageSelect />
  </div>
</div>

<style>
  @layer starlight.core {
    .capssa-header {
      display: flex;
      gap: var(--sl-nav-gap);
      justify-content: space-between;
      align-items: center;
      height: 100%;
    }
    .title-wrapper {
      gap: 0.75rem;
      align-items: center;
      padding: 0.25rem;
      margin: -0.25rem;
      min-width: 0;
    }
    .right-group,
    .social-icons {
      gap: 1rem;
      align-items: center;
    }
    .social-icons::after {
      content: '';
      height: 2rem;
      border-inline-end: 1px solid var(--sl-color-gray-5);
    }

    .top-nav {
      gap: 1.6rem;
      align-items: center;
      font-size: var(--sl-text-sm);
      font-weight: 500;
    }
    .top-nav a {
      color: var(--sl-color-gray-2);
      text-decoration: none;
      padding: 0.625rem 0.25rem;
      border-bottom: 2px solid transparent;
      transition: color 150ms ease, border-color 150ms ease;
    }
    .top-nav a:hover,
    .top-nav a[aria-current="page"] {
      color: var(--sl-color-white);
      border-bottom-color: var(--sl-color-text-accent);
    }
    .version-pill {
      font-family: var(--__sl-font-mono);
      font-size: var(--sl-text-xs);
      font-weight: 400;
      color: var(--sl-color-gray-3);
      padding: 0.25rem 0.65rem;
      border: 1px solid var(--sl-color-gray-5);
      border-radius: 999px;
      letter-spacing: -0.01em;
      white-space: nowrap;
      align-items: center;
      text-decoration: none;
      transition: color 150ms ease, border-color 150ms ease;
    }
    .version-pill:hover {
      color: var(--sl-color-white);
      border-color: var(--sl-color-gray-3);
    }

    @media (min-width: 50rem) {
      :global(:root[data-has-sidebar]) {
        --__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
      }
      :global(:root:not([data-has-toc])) {
        --__toc-width: 0rem;
      }
      .capssa-header {
        --__sidebar-width: max(0rem, var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x));
        --__main-column-fr: calc(
          (
              100% + var(--__sidebar-pad, 0rem) - var(--__toc-width, var(--sl-sidebar-width)) -
                (2 * var(--__toc-width, var(--sl-nav-pad-x))) - var(--sl-content-inline-start, 0rem) -
                var(--sl-content-width)
            ) / 2
        );
        display: grid;
        grid-template-columns:
          minmax(
            calc(var(--__sidebar-width) + max(0rem, var(--__main-column-fr) - var(--sl-nav-gap))),
            auto
          )
          auto
          1fr
          auto;
        align-content: center;
      }
      .top-nav { justify-self: start; }
      .search-cell { justify-self: end; }
    }
  }
</style>