coherent-docs-theme 1.0.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.
Files changed (40) hide show
  1. package/README.md +314 -0
  2. package/assets/gameface-ui-header-dark.svg +5 -0
  3. package/assets/gameface-ui-header-light.svg +5 -0
  4. package/components/Api.astro +29 -0
  5. package/components/BeforeAfter.astro +124 -0
  6. package/components/Details.astro +37 -0
  7. package/components/Enhancement.astro +29 -0
  8. package/components/Feature.astro +29 -0
  9. package/components/Figure.astro +107 -0
  10. package/components/Fix.astro +29 -0
  11. package/components/GallerySlider.astro +260 -0
  12. package/components/If.astro +6 -0
  13. package/components/IfEnv.astro +5 -0
  14. package/components/IfNot.astro +6 -0
  15. package/components/IncludeSnippets.astro +13 -0
  16. package/components/Internal.astro +3 -0
  17. package/components/ProductName.astro +13 -0
  18. package/components/Release.astro +68 -0
  19. package/components/SideBarWithDropdown.astro +8 -0
  20. package/components/Typeref.astro +35 -0
  21. package/index.ts +152 -0
  22. package/internal/overrideComponents.ts +29 -0
  23. package/internal/themeConfig.ts +21 -0
  24. package/internal-components/ChangelogRow.astro +39 -0
  25. package/internal-components/NavLinks.astro +253 -0
  26. package/internal-components/ProgressIndicator.astro +53 -0
  27. package/overrides/Footer.astro +103 -0
  28. package/overrides/Header.astro +91 -0
  29. package/overrides/Search.astro +234 -0
  30. package/overrides/ThemeSelect.astro +218 -0
  31. package/package.json +46 -0
  32. package/remark-directives/if.ts +51 -0
  33. package/remark-directives/includeSnippets.ts +120 -0
  34. package/remark-directives/index.ts +13 -0
  35. package/remark-directives/internal.ts +20 -0
  36. package/remark-directives/release.ts +29 -0
  37. package/styles.css +452 -0
  38. package/utils/changelogSideBar.ts +105 -0
  39. package/utils/changelogSideBarMultipleDocs.ts +119 -0
  40. package/utils/coherentReleases.ts +62 -0
package/README.md ADDED
@@ -0,0 +1,314 @@
1
+ # Coherent Docs Theme
2
+
3
+ A specialized [Starlight](https://starlight.astro.build/) theme designed for **Coherent Labs** documentation. It implements the **Gameface Design System**, offering a custom UI with distinct Dark/Light modes, sharp geometry, and integrated tooling for documentation management.
4
+
5
+ ## ✨ Features
6
+
7
+ * **Gameface Design System:**
8
+ * **Dark Mode:** "Deep Teal" (`#0F2123`) backgrounds for content, Coherent Black (`#0A0A0A`) for navigation.
9
+ * **Light Mode:** Clean white and light grey palette.
10
+ * **Typography:** Pre-configured `Barlow Semi Condensed` (Headings) and `Karla` (Body).
11
+ * **Geometry:** Strictly sharp corners (`0px` border-radius) on all UI elements.
12
+ * **Smart Navigation:**
13
+ * **Desktop:** Integrated header links alongside the logo.
14
+ * **Mobile:** Touch-friendly, horizontally scrollable navigation bar.
15
+ * **Sidebar:** Custom sidebar that prioritizes navigation links on mobile devices.
16
+ * **Asset Injection:** Automatically injects the Coherent Gameface logo on the left side of the header unless explicitly disabled.
17
+ * **Enhanced Components:**
18
+ * **Footer:** Automatic copyright year updating and legal links.
19
+ * **Progress Bar:** Optional reading progress indicator at the top of the page.
20
+ * **Bundled Tools:**
21
+ * `starlight-heading-badges`: Adds badges to headings.
22
+ * `starlight-sidebar-topics`: Support for multi-instance documentation.
23
+
24
+ ## 📦 Installation
25
+
26
+ Install the theme as a dependency in your documentation project:
27
+
28
+ ```bash
29
+ npm install coherent-docs-theme
30
+ ```
31
+
32
+ **Peer Dependencies**: Ensure your project meets the following requirements:
33
+
34
+ * `astro: ^5.0.0`
35
+ * `@astrojs/starlight: >=0.37.0`
36
+
37
+ ## 🚀 Usage
38
+
39
+ Add the theme to your `astro.config.mjs`.
40
+
41
+ ⚠️ Important: The `coherentTheme` function returns an array of plugins. **You must use the spread operator (...) when adding it to the plugins list in Starlight.**
42
+
43
+ ```js
44
+ // astro.config.mjs
45
+ import { defineConfig } from 'astro/config';
46
+ import starlight from '@astrojs/starlight';
47
+ import coherentTheme from 'coherent-docs-theme';
48
+
49
+ export default defineConfig({
50
+ integrations: [
51
+ starlight({
52
+ title: 'Gameface Documentation',
53
+ // Disable default credits to keep the footer clean
54
+ credits: false,
55
+
56
+ plugins: [
57
+ // ✅ CORRECT USAGE: Spread the array
58
+ ...coherentTheme({
59
+ documentationSearchTag: 'docs', // Tag to scope the search index for documentation content
60
+ showPageProgress: true,
61
+ // navLinks: [
62
+ // { label: 'Roadmap', href: '/roadmap' },
63
+ // { label: 'API', href: '/api' },
64
+ // { label: 'Showcase', href: 'https://coherent-labs.com' }
65
+ // ], // Aditional links to display in the header if needed
66
+ // disableDefaultLogo: false, // Set true if you want to use your own logo
67
+ // replacesTitle: false, // Set true if you want to show the documentation title next to the logo in the header. Useful when using a custom logo that doesn't include the title in it.
68
+ }),
69
+ ],
70
+
71
+ sidebar: [
72
+ {
73
+ label: 'Getting Started',
74
+ link: '/guides/getting-started'
75
+ }
76
+ ]
77
+ }),
78
+ ],
79
+ });
80
+ ```
81
+
82
+ ## ⚙️ Configuration Options
83
+
84
+ | Option | Type | Default | Description |
85
+ | -------------------------- | ------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
86
+ | **documentationSearchTag** | `string` | `''` | (Required) A tag to scope the search index for the documentation content. Also, used to show a button for the search resources filter for the current documentation. |
87
+ | **navLinks** | `Array<{ label, href }>` | `[]` | Links displayed in the header (desktop) and top-bar in the mobile menu (mobile). |
88
+ | **showPageProgress** | `boolean` | `false` | Shows a reading progress bar at the top of the page. |
89
+ | **disableDefaultLogo** | `boolean` | `false` | If false, injects the Gameface UI logo automatically if such is not defined in the Starlight config of the documentation. Set to true if you want to remove the logo entirely. |
90
+ | **replacesTitle** | `boolean` | `true` | If true, the logo will replace the title in the header. Set to false if you want to show the title next to the logo. Useful when using a custom logo that doesn't include the title in it. |
91
+
92
+ To override the default logo, simply provide your own in the Starlight configuration:
93
+
94
+ ```js
95
+ starlight({
96
+ logo: {
97
+ dark: './path/to/dark-logo.svg',
98
+ light: './path/to/light-logo.svg',
99
+ // If your logo already includes the title, set this to true to avoid duplication.
100
+ replacesTitle: false,
101
+ },
102
+ })
103
+ ```
104
+
105
+ ## 🛠️ Exported Utilities
106
+
107
+ The theme exports helper functions to streamline sidebar configuration and versioning.
108
+
109
+ * **generateVersionWithPackageJSON**
110
+
111
+ Reads a `package.json` file and generates a sidebar item with a version badge.
112
+
113
+ Usage:
114
+
115
+ ```js
116
+ import { generateVersionWithPackageJSON } from 'coherent-docs-theme';
117
+
118
+ // Inside astro.config.mjs -> starlight -> sidebar
119
+ sidebar: [
120
+ {
121
+ label: 'Core Package',
122
+ items: [
123
+ // Note: This is async, ensure your config supports top-level await
124
+ await generateVersionWithPackageJSON(
125
+ '../packages/core/package.json', // Path to package.json
126
+ 'https://www.npmjs.com/package/core' // (Optional) Link for the badge. If not provided, clicking the version will lead to the main documentation page.
127
+ ),
128
+ { label: 'Installation', link: '/core/install' }
129
+ ]
130
+ }
131
+ ]
132
+ ```
133
+
134
+ **Note: Provide the absolute path to the package.json file using the `path` module to ensure it works correctly regardless of the current working directory.**
135
+
136
+ * **generateDocsChangelog**
137
+
138
+ Generates a standard changelog link object for the sidebar. In the documentation it will create link to the provided changelog file and it will automatically extract all the versions from the file to display it as separate versions in the sidebar and will add a badge with the latest version next to the label.
139
+
140
+ ```js
141
+ import { generateDocsChangelog } from 'coherent-docs-theme';
142
+
143
+ sidebar: [
144
+ // ...
145
+ generateDocsChangelog(path.join(__dirname, `./src/content/docs/changelog/index.mdx`))
146
+ // Output: { label: 'Changelog', link: '/changelog' }
147
+ ]
148
+ ```
149
+
150
+ **Note: Provide the absolute path to the changelog file using the `path` module to ensure it works correctly regardless of the current working directory.**
151
+ **Note: Use this method if you have a single documentation section. If you are using sidebar topics for multiple documentation sections, use `generateMultipleDocsChangelog` instead to ensure the changelog is correctly associated with the corresponding topic.**
152
+
153
+ * **generateMultipleDocsChangelog**
154
+
155
+ Generates a changelog page link for multiple documentation sections. Use this method to generate changelog when documentation is generated using sidebar topics plugin. In the documentation it will create link to the provided changelog file and it will automatically extract all the versions from the file to display it as separate versions in the sidebar and will add a badge with the latest version next to the label.
156
+
157
+ ```js
158
+ import { generateDocsChangelog } from 'coherent-docs-theme';
159
+
160
+ sidebar: [
161
+ // ...
162
+ generateMultipleDocsChangelog('my-docs-name', path.join(__dirname, `./src/content/docs/my-docs-name/changelog/index.mdx`)),
163
+ // Output: { label: 'Changelog', link: '/my-docs-name/changelog' }
164
+ ]
165
+ ```
166
+
167
+ **Note: Provide the absolute path to the changelog file using the `path` module to ensure it works correctly regardless of the current working directory.**
168
+
169
+ ## 🎨 Styling & Customization
170
+
171
+ The theme comes with a pre-configured styles.
172
+
173
+ **Fonts**
174
+ The theme automatically imports and applies:
175
+
176
+ * **Headings**: `Barlow Semi Condensed`
177
+ * **Body**: `Karla`
178
+
179
+ Colors (CSS Variables)
180
+ You can use these variables in your custom components to match the theme:
181
+
182
+ ```css
183
+ /* Example Usage */
184
+ .my-component {
185
+ background-color: var(--gameface-bg-panel); /* Adapts to Dark/Light mode */
186
+ color: var(--gameface-cyan); /* The primary accent color */
187
+ border: 1px solid var(--gameface-border);
188
+ }
189
+ ```
190
+
191
+ To override or add the default styles, create a CSS file and add it to the `customCss` array in your Starlight configuration:
192
+
193
+ ```js
194
+ starlight({
195
+ // ...
196
+ customCss: [
197
+ './src/styles/custom.css', // Your custom styles
198
+ ],
199
+ // ...
200
+ })
201
+ ```
202
+
203
+ The variables and classes available can be found in the `styles.css` of the theme package. You can also inspect the generated CSS in the browser to see all available variables.
204
+
205
+ ## 📚 Multi-Instance Documentation (Sidebar Topics)
206
+
207
+ To organize multiple distinct documentation sections (e.g., "E2E", "Vite Plugin") within a single site, use the starlight-sidebar-topics plugin.
208
+
209
+ * **Define Topics:** Create an array of objects describing each section (`id`, `label`, `link`, `icon`, and `items`).
210
+ * **Register Plugin:** Add it to the plugins array in your Starlight config.
211
+
212
+ ```js
213
+ // astro.config.mjs
214
+ import starlightSidebarTopics from 'starlight-sidebar-topics';
215
+
216
+ const sideBarTopics = [
217
+ {
218
+ id: 'e2e',
219
+ label: 'Gameface E2E',
220
+ link: '/e2e/getting-started',
221
+ icon: 'rocket',
222
+ items: [
223
+ // Standard Starlight sidebar items (links, autogenerate, etc.)
224
+ { label: 'Getting Started', autogenerate: { directory: 'e2e/getting-started' } }
225
+ ]
226
+ },
227
+ // ... other topics
228
+ ];
229
+
230
+ export default defineConfig({
231
+ integrations: [
232
+ starlight({
233
+ plugins: [
234
+ starlightSidebarTopics(sideBarTopics, {
235
+ // Optional: Map specific pages (like changelogs) to a topic manually
236
+ topics: {
237
+ 'e2e': ['/e2e/changelog']
238
+ }
239
+ })
240
+ ]
241
+ })
242
+ ]
243
+ });
244
+ ```
245
+
246
+ * 🔽 Sidebar Context Switcher (Dropdown)
247
+
248
+ To display a dropdown menu at the top of the sidebar that allows users to switch between the defined topics, you must override the default Starlight Sidebar component with the specific component provided by the theme.
249
+
250
+ Configuration:
251
+
252
+ ```js
253
+ // astro.config.mjs
254
+ import coherentTheme from 'coherent-docs-theme';
255
+
256
+ export default defineConfig({
257
+ integrations: [
258
+ starlight({
259
+ plugins: [
260
+ ...coherentTheme(),
261
+ ],
262
+ // ...
263
+ components: {
264
+ // Point to the custom component exported by the theme
265
+ Sidebar: 'coherent-docs-theme/components/SidebarWithDropdown.astro',
266
+ },
267
+ }),
268
+ ],
269
+ });
270
+ ```
271
+
272
+ * Add redirects for each topic in `astro.config.mjs` to ensure the correct topic is highlighted when visiting the main page of each section (e.g., `/e2e` should redirect to `/e2e/getting-started`).
273
+
274
+ ```js
275
+ export default defineConfig({
276
+ integrations: [
277
+ starlight({
278
+ // ...
279
+ redirects: {
280
+ '/e2e': '/e2e/getting-started',
281
+ // Add more redirects for other topics as needed
282
+ }
283
+ })
284
+ ]
285
+ });
286
+ ```
287
+
288
+ * Generate changelog links for sidebar topics
289
+
290
+ To generate changelog links for each documentation section when using sidebar topics, use the `generateMultipleDocsChangelog` utility function provided by the theme. This function allows you to create a changelog link for each topic based on the corresponding changelog file.
291
+
292
+ ```js
293
+ import { generateMultipleDocsChangelog } from 'coherent-docs-theme';
294
+
295
+
296
+ const sideBarTopics = [
297
+ {
298
+ id: 'e2e',
299
+ label: 'Gameface E2E',
300
+ link: '/e2e/getting-started',
301
+ icon: 'rocket',
302
+ items: [
303
+ // Standard Starlight sidebar items (links, autogenerate, etc.)
304
+ { label: 'Getting Started', autogenerate: { directory: 'e2e/getting-started' } },
305
+ generateMultipleDocsChangelog('e2e', path.join(__dirname, `./src/content/docs/e2e/changelog/index.mdx`)),
306
+ ]
307
+ },
308
+ // ... other topics
309
+ ];
310
+ ```
311
+
312
+ ## 📝 License
313
+
314
+ MIT © Coherent Labs
@@ -0,0 +1,5 @@
1
+ <svg width="57" height="61" viewBox="0 0 57 61" fill="none"
2
+ xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M5.23954 11.4401L29.838 34.5279L51.2458 25.7258L51.5478 25.1221L23.4275 6.84267L5.23954 11.4401Z" fill="white" stroke="#999999" stroke-width="0.7"/>
4
+ <path d="M29.5574 34.4221L28.7764 54.4039L47.8622 44.6475L51.5359 25.5635L29.5574 34.4221Z" fill="white" stroke="#999999" stroke-width="0.7"/>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg width="57" height="61" viewBox="0 0 57 61" fill="none"
2
+ xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M5.23954 11.4401L29.838 34.5279L51.2458 25.7258L51.5478 25.1221L23.4275 6.84267L5.23954 11.4401Z" fill="white" fill-opacity="0.6" stroke="black" stroke-width="0.7"/>
4
+ <path d="M29.5574 34.4221L28.7764 54.4039L47.8622 44.6475L51.5359 25.5635L29.5574 34.4221Z" fill="white" fill-opacity="0.6" stroke="black" stroke-width="0.7"/>
5
+ </svg>
@@ -0,0 +1,29 @@
1
+ ---
2
+ import ChangelogRow, {
3
+ type ChangelogProps,
4
+ } from "../internal-components/ChangelogRow.astro";
5
+
6
+ interface Props extends ChangelogProps {}
7
+
8
+ const { engine, description } = Astro.props;
9
+ ---
10
+
11
+ {
12
+ Astro.slots.has("default") ? (
13
+ <ChangelogRow
14
+ badgeText="API"
15
+ badgeVariant="note"
16
+ engine={engine}
17
+ description={description}
18
+ >
19
+ <slot />
20
+ </ChangelogRow>
21
+ ) : (
22
+ <ChangelogRow
23
+ badgeText="API"
24
+ badgeVariant="note"
25
+ engine={engine}
26
+ description={description}
27
+ />
28
+ )
29
+ }
@@ -0,0 +1,124 @@
1
+ ---
2
+ import { Image } from "astro:assets";
3
+ import type { ImageMetadata } from "astro";
4
+
5
+ interface Props {
6
+ src1: string | ImageMetadata;
7
+ src2: string | ImageMetadata;
8
+ alt1?: string;
9
+ alt2?: string;
10
+ }
11
+
12
+ const { src1, src2, alt1 = "Before image", alt2 = "After image" } = Astro.props;
13
+
14
+ const isLocal1 = typeof src1 === "object";
15
+ const isLocal2 = typeof src2 === "object";
16
+ ---
17
+
18
+ <figure class="center">
19
+ <div class="image-slider">
20
+ <div class="slider-overlay">
21
+ {
22
+ isLocal1 ? (
23
+ <Image src={src1 as ImageMetadata} alt={alt1} />
24
+ ) : (
25
+ <img src={src1 as string} alt={alt1} />
26
+ )
27
+ }
28
+ </div>
29
+
30
+ {
31
+ isLocal2 ? (
32
+ <Image src={src2 as ImageMetadata} alt={alt2} />
33
+ ) : (
34
+ <img src={src2 as string} alt={alt2} />
35
+ )
36
+ }
37
+ </div>
38
+ </figure>
39
+
40
+ <style>
41
+ .center {
42
+ text-align: center;
43
+ margin: 2rem 0;
44
+ }
45
+
46
+ .image-slider {
47
+ position: relative;
48
+ display: inline-block;
49
+ line-height: 0;
50
+ }
51
+
52
+ .image-slider img {
53
+ user-select: none;
54
+ max-width: 70vw;
55
+ display: block;
56
+ height: auto;
57
+ margin: 0 !important;
58
+ padding: 0 !important;
59
+ }
60
+
61
+ .slider-overlay {
62
+ position: absolute;
63
+ top: 0;
64
+ bottom: 0;
65
+ left: 0;
66
+ width: 2%;
67
+ max-width: 100%;
68
+ overflow: hidden;
69
+ resize: horizontal;
70
+ border-right: 3px var(--before-after-line) solid;
71
+ box-sizing: border-box;
72
+ animation: slidejitter 2s ease-in-out 0.1s 1;
73
+ }
74
+
75
+ .slider-overlay:before {
76
+ position: absolute;
77
+ bottom: 3px;
78
+ right: 3px;
79
+ content: "";
80
+ display: block;
81
+ height: 3vw;
82
+ width: 3vw;
83
+ box-shadow: 3px 6px 2px 0 black;
84
+ overflow: hidden;
85
+ resize: horizontal;
86
+ background-clip: content-box;
87
+ background: linear-gradient(-45deg, white 50%, transparent 0);
88
+ }
89
+
90
+ @keyframes slidejitter {
91
+ 25% {
92
+ width: 2%;
93
+ }
94
+ 75% {
95
+ width: 5%;
96
+ }
97
+ 100% {
98
+ width: 2%;
99
+ }
100
+ }
101
+
102
+ @media (min-width: 600px) {
103
+ .image-slider img {
104
+ max-width: 50vw;
105
+ }
106
+ .slider-overlay:before {
107
+ width: 2vw;
108
+ height: 2vw;
109
+ }
110
+ }
111
+
112
+ @media (min-width: 1200px) {
113
+ .image-slider img {
114
+ max-width: 40vw;
115
+ }
116
+ .slider-overlay {
117
+ width: 10%;
118
+ }
119
+ .slider-overlay:before {
120
+ width: 1vw;
121
+ height: 1vw;
122
+ }
123
+ }
124
+ </style>
@@ -0,0 +1,37 @@
1
+ ---
2
+ interface Props {
3
+ summary: string;
4
+ [key: string]: any;
5
+ }
6
+
7
+ const { summary, ...rest } = Astro.props;
8
+
9
+ if (!summary) {
10
+ throw new Error("[Details Component] No summary provided!");
11
+ }
12
+ ---
13
+
14
+ <details {...rest}>
15
+ <summary>{summary}</summary>
16
+
17
+ <div class="details-content">
18
+ <slot />
19
+ </div>
20
+ </details>
21
+
22
+ <style>
23
+ .details-content {
24
+ margin-top: 1rem;
25
+ padding-left: 1rem;
26
+ border-left: 2px solid var(--sl-color-gray-5);
27
+ }
28
+
29
+ summary {
30
+ cursor: pointer;
31
+ font-weight: 600;
32
+ }
33
+
34
+ summary:hover {
35
+ color: var(--sl-color-accent);
36
+ }
37
+ </style>
@@ -0,0 +1,29 @@
1
+ ---
2
+ import ChangelogRow, {
3
+ type ChangelogProps,
4
+ } from "../internal-components/ChangelogRow.astro";
5
+
6
+ interface Props extends ChangelogProps {}
7
+
8
+ const { engine, description } = Astro.props;
9
+ ---
10
+
11
+ {
12
+ Astro.slots.has("default") ? (
13
+ <ChangelogRow
14
+ badgeText="Enhancement"
15
+ badgeVariant="success"
16
+ engine={engine}
17
+ description={description}
18
+ >
19
+ <slot />
20
+ </ChangelogRow>
21
+ ) : (
22
+ <ChangelogRow
23
+ badgeText="Enhancement"
24
+ badgeVariant="success"
25
+ engine={engine}
26
+ description={description}
27
+ />
28
+ )
29
+ }
@@ -0,0 +1,29 @@
1
+ ---
2
+ import ChangelogRow, {
3
+ type ChangelogProps,
4
+ } from "../internal-components/ChangelogRow.astro";
5
+
6
+ interface Props extends ChangelogProps {}
7
+
8
+ const { engine, description } = Astro.props;
9
+ ---
10
+
11
+ {
12
+ Astro.slots.has("default") ? (
13
+ <ChangelogRow
14
+ badgeText="Feature"
15
+ badgeVariant="note"
16
+ engine={engine}
17
+ description={description}
18
+ >
19
+ <slot />
20
+ </ChangelogRow>
21
+ ) : (
22
+ <ChangelogRow
23
+ badgeText="Feature"
24
+ badgeVariant="note"
25
+ engine={engine}
26
+ description={description}
27
+ />
28
+ )
29
+ }
@@ -0,0 +1,107 @@
1
+ ---
2
+ import { Image } from "astro:assets";
3
+ import type { ImageMetadata } from "astro";
4
+
5
+ interface Props {
6
+ src: string | ImageMetadata;
7
+ alt?: string;
8
+ caption?: string;
9
+ title?: string;
10
+ class?: string;
11
+ link?: string;
12
+ target?: string;
13
+ rel?: string;
14
+ width?: number | string;
15
+ height?: number | string;
16
+ attr?: string;
17
+ attrlink?: string;
18
+ }
19
+
20
+ const {
21
+ src,
22
+ alt,
23
+ caption,
24
+ title,
25
+ class: className,
26
+ link,
27
+ target,
28
+ rel,
29
+ width,
30
+ height,
31
+ attr,
32
+ attrlink,
33
+ } = Astro.props;
34
+
35
+ const isLocal = typeof src === "object";
36
+ const altText = alt || caption || "";
37
+ ---
38
+
39
+ <figure class={className}>
40
+ {
41
+ link ? (
42
+ <a href={link} target={target} rel={rel}>
43
+ {isLocal ? (
44
+ <Image
45
+ src={src as ImageMetadata}
46
+ alt={altText}
47
+ title={title}
48
+ width={width as any}
49
+ height={height as any}
50
+ />
51
+ ) : (
52
+ <img
53
+ src={src as string}
54
+ alt={altText}
55
+ title={title}
56
+ width={width}
57
+ height={height}
58
+ />
59
+ )}
60
+ </a>
61
+ ) : isLocal ? (
62
+ <Image
63
+ src={src as ImageMetadata}
64
+ alt={altText}
65
+ title={title}
66
+ width={width as any}
67
+ height={height as any}
68
+ />
69
+ ) : (
70
+ <img
71
+ src={src as string}
72
+ alt={altText}
73
+ title={title}
74
+ width={width}
75
+ height={height}
76
+ />
77
+ )
78
+ }
79
+
80
+ {
81
+ (caption || attr) && (
82
+ <figcaption>
83
+ {caption && <p>{caption}</p>}
84
+
85
+ {attr && (
86
+ <p>{attrlink ? <a href={attrlink}>{attr}</a> : attr}</p>
87
+ )}
88
+ </figcaption>
89
+ )
90
+ }
91
+ </figure>
92
+
93
+ <style>
94
+ figure {
95
+ margin: 2rem 0;
96
+ text-align: center;
97
+ }
98
+ figcaption {
99
+ margin-top: 0.5rem;
100
+ font-size: 0.9rem;
101
+ color: var(--sl-color-gray-3);
102
+ text-align: start;
103
+ }
104
+ figcaption p {
105
+ margin: 0;
106
+ }
107
+ </style>