maverick-wave-astro 1.2.0 → 1.3.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.
@@ -0,0 +1,42 @@
1
+ ---
2
+ // The item ids count from 1 and are link targets: #frage-3 opens the third one.
3
+ import { answerParagraphs, type Question } from '../dist/faq.js';
4
+
5
+ interface Props {
6
+ items: readonly Question[];
7
+ idPrefix: string;
8
+ variant?: 'lines' | 'cards';
9
+ firstOpen?: boolean;
10
+ single?: boolean;
11
+ class?: string;
12
+ }
13
+
14
+ const {
15
+ items,
16
+ idPrefix,
17
+ variant = 'lines',
18
+ firstOpen = false,
19
+ single = false,
20
+ class: className,
21
+ } = Astro.props;
22
+ ---
23
+
24
+ <div class:list={['mw-faq', variant === 'cards' && 'mw-faq-cards', className]}>
25
+ {
26
+ items.map((item, index) => (
27
+ <details
28
+ class="mw-faq-item"
29
+ id={`${idPrefix}${index + 1}`}
30
+ name={single ? idPrefix : undefined}
31
+ open={firstOpen && index === 0}
32
+ >
33
+ <summary class="mw-faq-question">{item.question}</summary>
34
+ <div class="mw-faq-answer">
35
+ {answerParagraphs(item.answer).map(paragraph => (
36
+ <p>{paragraph}</p>
37
+ ))}
38
+ </div>
39
+ </details>
40
+ ))
41
+ }
42
+ </div>
@@ -11,9 +11,11 @@ const { title, notice, noticeType = 'warning' } = Astro.props;
11
11
  ---
12
12
 
13
13
  <section class="mw-section">
14
- <div class="mw-container mw-content mw-prose">
15
- <h1>{title}</h1>
16
- {notice && <div class={`mw-alert mw-alert-${noticeType}`}>{notice}</div>}
17
- <slot />
14
+ <div class="mw-container mw-content">
15
+ <div class="mw-container-narrow mw-prose">
16
+ <h1>{title}</h1>
17
+ {notice && <div class={`mw-alert mw-alert-${noticeType}`}>{notice}</div>}
18
+ <slot />
19
+ </div>
18
20
  </div>
19
21
  </section>
package/dist/faq.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export type Question = {
2
+ question: string;
3
+ answer: string | readonly string[];
4
+ };
5
+ export declare const answerParagraphs: (answer: Question["answer"]) => readonly string[];
6
+ export declare const faqPage: (questions: readonly Question[], id: string) => {
7
+ '@type': string;
8
+ '@id': string;
9
+ mainEntity: {
10
+ '@type': string;
11
+ name: string;
12
+ acceptedAnswer: {
13
+ '@type': string;
14
+ text: string;
15
+ };
16
+ }[];
17
+ };
package/dist/faq.js ADDED
@@ -0,0 +1,14 @@
1
+ export const answerParagraphs = (answer) => typeof answer === 'string' ? [answer] : answer;
2
+ // Built from the list the page shows - Google drops the markup when the two differ.
3
+ export const faqPage = (questions, id) => ({
4
+ '@type': 'FAQPage',
5
+ '@id': id,
6
+ mainEntity: questions.map(({ question, answer }) => ({
7
+ '@type': 'Question',
8
+ name: question,
9
+ acceptedAnswer: {
10
+ '@type': 'Answer',
11
+ text: answerParagraphs(answer).join(' '),
12
+ },
13
+ })),
14
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maverick-wave-astro",
3
- "version": "1.2.0",
3
+ "version": "1.3.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",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "peerDependencies": {
53
53
  "astro": "^7.2.0",
54
- "maverick-wave": "^5.36.0"
54
+ "maverick-wave": "^5.37.0"
55
55
  },
56
56
  "dependencies": {
57
57
  "@astrojs/sitemap": "^3.7.3",
@@ -66,7 +66,7 @@
66
66
  "eslint-plugin-astro": "^1.5.0",
67
67
  "eslint-plugin-simple-import-sort": "^12.1.1",
68
68
  "globals": "^16.5.0",
69
- "maverick-wave": "^5.36.0",
69
+ "maverick-wave": "^5.37.0",
70
70
  "prettier": "^3.6.2",
71
71
  "prettier-plugin-astro": "^0.14.1",
72
72
  "typescript": "^6.0.3",