@dogsbay/docs-layout 0.2.0-beta.175 → 0.2.0-beta.177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/docs-layout",
3
- "version": "0.2.0-beta.175",
3
+ "version": "0.2.0-beta.177",
4
4
  "description": "Standard documentation layout components for Dogsbay",
5
5
  "type": "module",
6
6
  "exports": {
@@ -37,11 +37,11 @@
37
37
  "./section-switcher.css": "./src/section-switcher.css"
38
38
  },
39
39
  "dependencies": {
40
- "@dogsbay/elements": "0.2.0-beta.175",
41
- "@dogsbay/primitives": "0.2.0-beta.175",
42
- "@dogsbay/search": "0.2.0-beta.175",
43
- "@dogsbay/site-files": "0.2.0-beta.175",
44
- "@dogsbay/ui": "0.2.0-beta.175"
40
+ "@dogsbay/elements": "0.2.0-beta.177",
41
+ "@dogsbay/primitives": "0.2.0-beta.177",
42
+ "@dogsbay/search": "0.2.0-beta.177",
43
+ "@dogsbay/site-files": "0.2.0-beta.177",
44
+ "@dogsbay/ui": "0.2.0-beta.177"
45
45
  },
46
46
  "devDependencies": {
47
47
  "happy-dom": "^20.10.6",
@@ -528,6 +528,12 @@ interface Props {
528
528
  * `poweredBy: false` in dogsbay.config.yml. See docs/powered-by.md.
529
529
  */
530
530
  poweredBy?: boolean;
531
+ /**
532
+ * Link previews for readers (`linkPreviews: true` in dogsbay.config.yml, off by default): a card
533
+ * with the target's title, section and excerpt after a moment of hover or keyboard focus on a
534
+ * link in the page's content (`@dogsbay/elements/link-previews`). See docs/link-previews.md.
535
+ */
536
+ linkPreviews?: boolean;
531
537
  /**
532
538
  * The site's chrome (`chrome` in site.json, format-astro's `chromeData`): logo, colour mode,
533
539
  * announcement bar, header links, social icons, footer columns. With it, the header's
@@ -540,6 +546,7 @@ interface Props {
540
546
 
541
547
  const {
542
548
  poweredBy = false,
549
+ linkPreviews = false,
543
550
  siteChrome,
544
551
  siteName,
545
552
  siteTagline,
@@ -1368,6 +1375,7 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1368
1375
  <main
1369
1376
  class="min-w-0 flex-1 px-6 py-8 lg:px-12"
1370
1377
  data-pagefind-body={excludeFromSearch ? undefined : ""}
1378
+ data-link-previews={linkPreviews ? "" : undefined}
1371
1379
  >
1372
1380
  {/*
1373
1381
  Pagefind facet filter elements. Placed inside the
@@ -1670,3 +1678,21 @@ const siteIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
1670
1678
  updateActiveNav();
1671
1679
  });
1672
1680
  </script>
1681
+
1682
+ <script>
1683
+ // Link previews (`linkPreviews: true`): the client is loaded only on a page that asks for it
1684
+ // (`<main data-link-previews>`), once for the visit; it listens on the document, so pages a
1685
+ // client router swaps in are covered. See docs/link-previews.md.
1686
+ let linkPreviewsStarted = false;
1687
+ function startLinkPreviews() {
1688
+ if (linkPreviewsStarted || !document.querySelector("main[data-link-previews]")) return;
1689
+ linkPreviewsStarted = true;
1690
+ import("@dogsbay/elements/link-previews")
1691
+ .then(({ initLinkPreviews }) => initLinkPreviews({ content: "main[data-link-previews] article.docs-prose" }))
1692
+ .catch(() => {
1693
+ linkPreviewsStarted = false;
1694
+ });
1695
+ }
1696
+ startLinkPreviews();
1697
+ document.addEventListener("astro:page-load", startLinkPreviews);
1698
+ </script>