maverick-wave-astro 1.5.0 → 1.6.0

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.
@@ -4,7 +4,9 @@
4
4
  import { config } from '../dist/config.js';
5
5
  import { PACKAGE_ICONS } from '../dist/icons.js';
6
6
  import { withBase } from '../dist/path.js';
7
+ import { breadcrumbList } from '../dist/structured-data.js';
7
8
  import Icon from './Icon.astro';
9
+ import JsonLd from './JsonLd.astro';
8
10
 
9
11
  interface Props {
10
12
  items: readonly { label: string; href: string }[];
@@ -27,6 +29,9 @@ const {
27
29
  small = false,
28
30
  class: className = 'mw-mt-8 mw-mb-8',
29
31
  } = Astro.props;
32
+ const trail = Astro.site
33
+ ? breadcrumbList([{ label: homeLabel, href: homeHref }, ...items], Astro.site)
34
+ : null;
30
35
  ---
31
36
 
32
37
  <nav
@@ -67,3 +72,4 @@ const {
67
72
  }
68
73
  </ol>
69
74
  </nav>
75
+ {trail && <JsonLd data={trail} />}
@@ -1 +1,16 @@
1
1
  export declare const jsonLdText: (data: unknown) => string;
2
+ export type Crumb = {
3
+ label: string;
4
+ href: string;
5
+ };
6
+ /** The trail the Breadcrumbs component shows, start page first, as absolute URLs. */
7
+ export declare const breadcrumbList: (crumbs: readonly Crumb[], site: URL | string) => {
8
+ '@context': string;
9
+ '@type': string;
10
+ itemListElement: {
11
+ '@type': string;
12
+ position: number;
13
+ name: string;
14
+ item: string;
15
+ }[];
16
+ };
@@ -1,2 +1,13 @@
1
1
  // Without the escape a "</script>" inside any text ends the block early.
2
2
  export const jsonLdText = (data) => JSON.stringify(data).replace(/</g, '\\u003c');
3
+ /** The trail the Breadcrumbs component shows, start page first, as absolute URLs. */
4
+ export const breadcrumbList = (crumbs, site) => ({
5
+ '@context': 'https://schema.org',
6
+ '@type': 'BreadcrumbList',
7
+ itemListElement: crumbs.map((crumb, index) => ({
8
+ '@type': 'ListItem',
9
+ position: index + 1,
10
+ name: crumb.label,
11
+ item: new URL(crumb.href, site).href,
12
+ })),
13
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maverick-wave-astro",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Shared frame for static Astro homepages built with MaverickWave: layout, SEO, design variants, schedule, building blocks.",
5
5
  "type": "module",
6
6
  "license": "MIT",