@writedocs/generator 0.13.3 → 0.13.5

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 (87) hide show
  1. package/README.md +28 -28
  2. package/astro.config.mjs +645 -645
  3. package/bin/writedocs.js +43 -12
  4. package/package.json +99 -99
  5. package/src/cli/base-path-layout.js +44 -44
  6. package/src/cli/build-auth.js +135 -135
  7. package/src/cli/build.js +203 -203
  8. package/src/cli/check-built-styles.js +41 -41
  9. package/src/cli/convert.js +1 -1
  10. package/src/cli/dev.js +268 -268
  11. package/src/cli/exit-when-flushed.js +4 -0
  12. package/src/cli/generate-api-pages.js +507 -507
  13. package/src/cli/og-image-worker.js +20 -20
  14. package/src/cli/og-images.js +70 -70
  15. package/src/cli/page-list-watch.js +69 -69
  16. package/src/cli/run-astro.js +97 -97
  17. package/src/cli/run-pagefind.js +154 -154
  18. package/src/cli/write-mcp-files.js +103 -103
  19. package/src/cli/write-redirects-file.js +158 -158
  20. package/src/components/ApiReferencePanel.astro +1792 -1792
  21. package/src/components/AppIcon.astro +51 -51
  22. package/src/components/Card.astro +193 -193
  23. package/src/components/CodeGroup.astro +63 -39
  24. package/src/components/CopyPageMenu.astro +374 -374
  25. package/src/components/Hint.astro +188 -188
  26. package/src/components/Icon.astro +72 -72
  27. package/src/components/Image.astro +165 -165
  28. package/src/components/Tile.astro +67 -67
  29. package/src/components/Video.astro +137 -137
  30. package/src/content.config.ts +203 -203
  31. package/src/layout/BaseLayout.astro +908 -908
  32. package/src/layout/components/AnalyticsScripts.astro +49 -49
  33. package/src/layout/components/Breadcrumbs.astro +98 -98
  34. package/src/layout/components/ConsentBanner.astro +119 -119
  35. package/src/layout/components/MobileMenu.astro +225 -225
  36. package/src/layout/components/NavTree.astro +408 -408
  37. package/src/layout/components/Sidebar.astro +232 -232
  38. package/src/layout/components/SiteFooter.astro +87 -87
  39. package/src/layout/components/TopBar.astro +386 -386
  40. package/src/layout/styles/base.css +332 -326
  41. package/src/layout/styles/mobile-menu.css +285 -285
  42. package/src/lib/agent-markdown.js +164 -164
  43. package/src/lib/asset-dimensions.js +89 -89
  44. package/src/lib/base-path.js +90 -90
  45. package/src/lib/cli-report.js +22 -22
  46. package/src/lib/code-line-numbers.js +13 -0
  47. package/src/lib/config-schema.js +414 -75
  48. package/src/lib/config-schema.ts +2509 -1905
  49. package/src/lib/config.ts +1316 -1314
  50. package/src/lib/consent.js +108 -108
  51. package/src/lib/content-store-reload-integration.js +101 -101
  52. package/src/lib/icon-data-dev.js +53 -53
  53. package/src/lib/image-size.js +152 -152
  54. package/src/lib/json-schema-descriptions.js +228 -228
  55. package/src/lib/link-check.js +544 -544
  56. package/src/lib/llms-index.ts +90 -90
  57. package/src/lib/mcp-dev-integration.js +65 -65
  58. package/src/lib/mcp-index.ts +102 -102
  59. package/src/lib/mintlify-convert.js +605 -605
  60. package/src/lib/moved-api-pages.js +49 -49
  61. package/src/lib/og-cards.js +33 -33
  62. package/src/lib/og-image.js +235 -235
  63. package/src/lib/openapi-dev-status.js +80 -80
  64. package/src/lib/openapi-reload-integration.js +193 -193
  65. package/src/lib/pages.js +312 -312
  66. package/src/lib/project-files-integration.js +116 -116
  67. package/src/lib/project-files.js +137 -137
  68. package/src/lib/rehype-base-path.js +62 -62
  69. package/src/lib/rehype-image-loading.js +71 -71
  70. package/src/lib/robots-txt.js +21 -21
  71. package/src/lib/search-scope.js +44 -44
  72. package/src/lib/selector-placement.js +50 -50
  73. package/src/lib/seo-tags.js +155 -155
  74. package/src/lib/shiki-code-block.js +7 -1
  75. package/src/lib/site-base.ts +27 -27
  76. package/src/lib/styles-asset-integration.js +291 -291
  77. package/src/lib/wdignore-cases.json +195 -195
  78. package/src/lib/wdignore.js +177 -177
  79. package/src/pages/404.astro +63 -63
  80. package/src/pages/[...slug].astro +1762 -1608
  81. package/src/pages/[...slug].md.ts +93 -93
  82. package/src/pages/llms-full.txt.ts +88 -88
  83. package/src/pages/og/[...slug].png.ts +63 -63
  84. package/src/scripts/mobile-menu.ts +80 -80
  85. package/src/scripts/search.ts +245 -245
  86. package/src/scripts/sidebar-scroll.ts +61 -61
  87. package/src/styles/global.css +40 -40
@@ -1,165 +1,165 @@
1
- ---
2
- import { extraClasses } from './class-names';
3
- import { imageFileFor, imageSize } from '../lib/image-size.js';
4
- import { siteHref } from '../lib/site-base';
5
- // Block-level (own line, centered) - unlike Hint (inline/text-level),
6
- // this is meant to be dropped in on its own the way Callout/Card are.
7
- //
8
- // src/srcDark render as two separate <img> tags, both always in the
9
- // markup, CSS shows only the one matching the active [data-theme] - the
10
- // exact same dual light/dark-asset pattern base.css's own .wd-logo-light/
11
- // .wd-logo-dark rules already establish for TopBar/MobileMenu/SiteFooter's
12
- // logo (see that comment there) - base.css's own comment on those rules
13
- // spells out exactly why they get to write [data-theme='dark'] .wd-logo-x
14
- // completely unscoped: base.css is a *plain imported* .css file, never run
15
- // through Astro's scoped-CSS compiler at all, unlike this component's own
16
- // <style> block below. [data-theme] lives on <html>, set by BaseLayout's
17
- // anti-FOUC script - nowhere near this component's own template - so
18
- // inside a *scoped* <style> (this one) that ancestor selector has to be
19
- // wrapped in :global() or Astro's compiler appends this component's own
20
- // scope attribute onto it too, requiring <html> to carry that attribute,
21
- // which it never will. .wd-image-light/.wd-image-dark themselves don't
22
- // need :global() - unlike AppIcon-rendered markup (Card/Accordion's own
23
- // icon rules), both <img> tags here are rendered directly by *this*
24
- // component's own template, so they already carry its scope attribute
25
- // normally.
26
- interface Props {
27
- src: string;
28
- srcDark?: string;
29
- // Width at full (unconstrained) viewport width - a raw CSS length or
30
- // percentage string ("80%", "480px", "40rem", ...), passed straight
31
- // through as a custom property with no parsing/validation, the same
32
- // "trust the site author, this is their writedocs.json/content" latitude
33
- // every other pass-through string prop here already gets (Card's
34
- // icon, Callout's title, ...). Applied to the *figure* (see below),
35
- // not the <img> tags directly - an earlier version set it on the img
36
- // instead, which left the figure itself (and, when caption is set,
37
- // its whole bordered card) always full-width regardless of `size`,
38
- // so a size="70%" image ended up sitting inside a card twice as wide
39
- // as it needed to be, with a large empty gap on both sides - caught
40
- // via a real screenshot showing exactly that gap. max-width: 100%
41
- // below is what actually makes this shrink on a narrower viewport
42
- // instead of overflowing it, regardless of which form `size` takes -
43
- // a percentage already scales with its container on its own, but a
44
- // fixed px/rem value doesn't, and needs that separate cap to behave
45
- // the same way.
46
- size?: string;
47
- alt?: string;
48
- // Optional caption shown below the image. Set it and the whole thing
49
- // gains the same bordered/rounded "card" background Frame's own
50
- // caption case uses (border + background + padding, image inset
51
- // inside it) - deliberately conditional on caption being set rather
52
- // than always-on: without a caption this needs to render exactly as
53
- // it always has (a plain image, no chrome), so an existing
54
- // <Image src="..." /> with no caption keeps its current look with
55
- // zero visual change - only opting a page into the card look actually
56
- // opts it in.
57
- caption?: string;
58
- // Opts this image out of the site-wide click-to-zoom lightbox (see
59
- // src/scripts/image-zoom.ts) - rendered as a bare `nozoom` attribute
60
- // on both <img> tags, the same attribute a raw
61
- // `<img nozoom src="..." />` written directly in MDX would carry, so
62
- // lib/image-zoom-rules.js handles both cases identically rather than
63
- // needing to special-case this component.
64
- noZoom?: boolean;
65
- // "lazy" (the default): the browser fetches the image when the reader
66
- // gets near it. "eager": with the page - for an image at the very top.
67
- // The page's first image gets "eager" by itself
68
- // (lib/rehype-image-loading.js).
69
- loading?: "lazy" | "eager";
70
- }
71
- const { src, srcDark, size, alt = "", caption, noZoom, loading = "lazy" } = Astro.props as Props;
72
- // Each file's own pixel size, as width/height: the browser keeps the
73
- // image's place before it arrives, so the text below doesn't jump. The
74
- // CSS below already has height: auto, so the image still scales.
75
- const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
76
- const sizeOf = (address?: string) => {
77
- const file = address ? imageFileFor(address, contentDir) : null;
78
- return (file && imageSize(file, contentDir)) || { width: undefined, height: undefined };
79
- };
80
- const light = sizeOf(src);
81
- const dark = sizeOf(srcDark);
82
- const sizeStyle = size ? `--wd-image-size:${size}` : undefined;
83
- ---
84
-
85
- <figure
86
- class:list={["wd-image-figure", caption && "wd-image-figure-framed", srcDark && "wd-image-has-dark", extraClasses(Astro.props)]}
87
- style={sizeStyle}
88
- >
89
- <img src={siteHref(src)} alt={alt} class="wd-image wd-image-light" nozoom={noZoom || undefined} loading={loading} decoding="async" width={light.width} height={light.height} />
90
- {srcDark && <img src={siteHref(srcDark)} alt={alt} class="wd-image wd-image-dark" nozoom={noZoom || undefined} loading={loading} decoding="async" width={dark.width} height={dark.height} />}
91
- {caption && <figcaption class="wd-image-caption">{caption}</figcaption>}
92
- </figure>
93
- <style>
94
- /* width: var(--wd-image-size, 100%) here (not on the img - see the
95
- `size` prop's own comment above) is what makes the *whole figure*,
96
- card background and all, actually match the image's own size
97
- instead of always spanning the full content column. margin: ...
98
- auto only has anything to center once this has a definite width
99
- smaller than its container - at the 100% default it's a no-op,
100
- same as before this prop existed. */
101
- .wd-image-figure {
102
- width: var(--wd-image-size, 100%);
103
- max-width: 100%;
104
- margin: 1.25rem auto;
105
- }
106
- /* Same card language as Frame's own bordered case (border + rounded +
107
- surface background + padding) - deliberately duplicated here rather
108
- than shared, the same way Card/Callout/Accordion each carry their
109
- own near-identical CSS rather than a shared base class; Astro's
110
- scoped <style> blocks are per-component anyway, so there's no
111
- lighter-weight way to share this without introducing a global
112
- stylesheet dependency neither component otherwise needs. Padding
113
- is what creates the "image inset within the card" look - the img's
114
- own width: 100% below resolves against this padded content box,
115
- not the figure's own outer edge.
116
- box-shadow is a deliberate belt-and-suspenders addition on top of
117
- the border - var(--wd-border)/var(--wd-surface) are both very
118
- light, low-contrast tokens by default (see BaseLayout.astro's own
119
- --wd-border/--wd-surface light-mode values), so on a page whose own
120
- background is similarly pale (or, worse, uses the literal same
121
- image asset as its background - confirmed as the actual root cause
122
- of a real earlier "the card is invisible" report), the border alone
123
- can end up nearly imperceptible even though it's genuinely being
124
- applied. A soft shadow gives the card a second, independent visual
125
- cue that doesn't depend on border/surface contrast against
126
- whatever the page happens to look like. */
127
- .wd-image-figure-framed {
128
- border: 1px solid var(--wd-border);
129
- border-radius: 0.75rem;
130
- background: var(--wd-surface);
131
- padding: 0.5rem;
132
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
133
- }
134
- .wd-image {
135
- display: block;
136
- width: 100%;
137
- height: auto;
138
- border-radius: 0.75rem;
139
- }
140
- .wd-image-dark {
141
- display: none;
142
- }
143
- /* .wd-image-light only hides in dark mode when a dark variant is
144
- actually there to replace it - .wd-image-has-dark only gets added
145
- to the figure when srcDark is set (see the frontmatter above); with
146
- no srcDark, there's no second <img> in the markup at all, so
147
- unconditionally hiding the light one (an earlier version of this
148
- rule had no such scoping) left dark mode with literally nothing to
149
- show - a real user report caught exactly that: light-only Image
150
- usages went blank in dark mode instead of just keeping the one
151
- image they had, same as base.css's own dual-logo comment already
152
- notes for a site that only configures one logo. */
153
- :global([data-theme="dark"]) .wd-image-figure.wd-image-has-dark .wd-image-light {
154
- display: none;
155
- }
156
- :global([data-theme="dark"]) .wd-image-dark {
157
- display: block;
158
- }
159
- .wd-image-caption {
160
- margin-top: 0.6rem;
161
- text-align: center;
162
- color: var(--wd-text);
163
- font-size: 0.75rem;
164
- }
165
- </style>
1
+ ---
2
+ import { extraClasses } from './class-names';
3
+ import { imageFileFor, imageSize } from '../lib/image-size.js';
4
+ import { siteHref } from '../lib/site-base';
5
+ // Block-level (own line, centered) - unlike Hint (inline/text-level),
6
+ // this is meant to be dropped in on its own the way Callout/Card are.
7
+ //
8
+ // src/srcDark render as two separate <img> tags, both always in the
9
+ // markup, CSS shows only the one matching the active [data-theme] - the
10
+ // exact same dual light/dark-asset pattern base.css's own .wd-logo-light/
11
+ // .wd-logo-dark rules already establish for TopBar/MobileMenu/SiteFooter's
12
+ // logo (see that comment there) - base.css's own comment on those rules
13
+ // spells out exactly why they get to write [data-theme='dark'] .wd-logo-x
14
+ // completely unscoped: base.css is a *plain imported* .css file, never run
15
+ // through Astro's scoped-CSS compiler at all, unlike this component's own
16
+ // <style> block below. [data-theme] lives on <html>, set by BaseLayout's
17
+ // anti-FOUC script - nowhere near this component's own template - so
18
+ // inside a *scoped* <style> (this one) that ancestor selector has to be
19
+ // wrapped in :global() or Astro's compiler appends this component's own
20
+ // scope attribute onto it too, requiring <html> to carry that attribute,
21
+ // which it never will. .wd-image-light/.wd-image-dark themselves don't
22
+ // need :global() - unlike AppIcon-rendered markup (Card/Accordion's own
23
+ // icon rules), both <img> tags here are rendered directly by *this*
24
+ // component's own template, so they already carry its scope attribute
25
+ // normally.
26
+ interface Props {
27
+ src: string;
28
+ srcDark?: string;
29
+ // Width at full (unconstrained) viewport width - a raw CSS length or
30
+ // percentage string ("80%", "480px", "40rem", ...), passed straight
31
+ // through as a custom property with no parsing/validation, the same
32
+ // "trust the site author, this is their writedocs.json/content" latitude
33
+ // every other pass-through string prop here already gets (Card's
34
+ // icon, Callout's title, ...). Applied to the *figure* (see below),
35
+ // not the <img> tags directly - an earlier version set it on the img
36
+ // instead, which left the figure itself (and, when caption is set,
37
+ // its whole bordered card) always full-width regardless of `size`,
38
+ // so a size="70%" image ended up sitting inside a card twice as wide
39
+ // as it needed to be, with a large empty gap on both sides - caught
40
+ // via a real screenshot showing exactly that gap. max-width: 100%
41
+ // below is what actually makes this shrink on a narrower viewport
42
+ // instead of overflowing it, regardless of which form `size` takes -
43
+ // a percentage already scales with its container on its own, but a
44
+ // fixed px/rem value doesn't, and needs that separate cap to behave
45
+ // the same way.
46
+ size?: string;
47
+ alt?: string;
48
+ // Optional caption shown below the image. Set it and the whole thing
49
+ // gains the same bordered/rounded "card" background Frame's own
50
+ // caption case uses (border + background + padding, image inset
51
+ // inside it) - deliberately conditional on caption being set rather
52
+ // than always-on: without a caption this needs to render exactly as
53
+ // it always has (a plain image, no chrome), so an existing
54
+ // <Image src="..." /> with no caption keeps its current look with
55
+ // zero visual change - only opting a page into the card look actually
56
+ // opts it in.
57
+ caption?: string;
58
+ // Opts this image out of the site-wide click-to-zoom lightbox (see
59
+ // src/scripts/image-zoom.ts) - rendered as a bare `nozoom` attribute
60
+ // on both <img> tags, the same attribute a raw
61
+ // `<img nozoom src="..." />` written directly in MDX would carry, so
62
+ // lib/image-zoom-rules.js handles both cases identically rather than
63
+ // needing to special-case this component.
64
+ noZoom?: boolean;
65
+ // "lazy" (the default): the browser fetches the image when the reader
66
+ // gets near it. "eager": with the page - for an image at the very top.
67
+ // The page's first image gets "eager" by itself
68
+ // (lib/rehype-image-loading.js).
69
+ loading?: "lazy" | "eager";
70
+ }
71
+ const { src, srcDark, size, alt = "", caption, noZoom, loading = "lazy" } = Astro.props as Props;
72
+ // Each file's own pixel size, as width/height: the browser keeps the
73
+ // image's place before it arrives, so the text below doesn't jump. The
74
+ // CSS below already has height: auto, so the image still scales.
75
+ const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
76
+ const sizeOf = (address?: string) => {
77
+ const file = address ? imageFileFor(address, contentDir) : null;
78
+ return (file && imageSize(file, contentDir)) || { width: undefined, height: undefined };
79
+ };
80
+ const light = sizeOf(src);
81
+ const dark = sizeOf(srcDark);
82
+ const sizeStyle = size ? `--wd-image-size:${size}` : undefined;
83
+ ---
84
+
85
+ <figure
86
+ class:list={["wd-image-figure", caption && "wd-image-figure-framed", srcDark && "wd-image-has-dark", extraClasses(Astro.props)]}
87
+ style={sizeStyle}
88
+ >
89
+ <img src={siteHref(src)} alt={alt} class="wd-image wd-image-light" nozoom={noZoom || undefined} loading={loading} decoding="async" width={light.width} height={light.height} />
90
+ {srcDark && <img src={siteHref(srcDark)} alt={alt} class="wd-image wd-image-dark" nozoom={noZoom || undefined} loading={loading} decoding="async" width={dark.width} height={dark.height} />}
91
+ {caption && <figcaption class="wd-image-caption">{caption}</figcaption>}
92
+ </figure>
93
+ <style>
94
+ /* width: var(--wd-image-size, 100%) here (not on the img - see the
95
+ `size` prop's own comment above) is what makes the *whole figure*,
96
+ card background and all, actually match the image's own size
97
+ instead of always spanning the full content column. margin: ...
98
+ auto only has anything to center once this has a definite width
99
+ smaller than its container - at the 100% default it's a no-op,
100
+ same as before this prop existed. */
101
+ .wd-image-figure {
102
+ width: var(--wd-image-size, 100%);
103
+ max-width: 100%;
104
+ margin: 1.25rem auto;
105
+ }
106
+ /* Same card language as Frame's own bordered case (border + rounded +
107
+ surface background + padding) - deliberately duplicated here rather
108
+ than shared, the same way Card/Callout/Accordion each carry their
109
+ own near-identical CSS rather than a shared base class; Astro's
110
+ scoped <style> blocks are per-component anyway, so there's no
111
+ lighter-weight way to share this without introducing a global
112
+ stylesheet dependency neither component otherwise needs. Padding
113
+ is what creates the "image inset within the card" look - the img's
114
+ own width: 100% below resolves against this padded content box,
115
+ not the figure's own outer edge.
116
+ box-shadow is a deliberate belt-and-suspenders addition on top of
117
+ the border - var(--wd-border)/var(--wd-surface) are both very
118
+ light, low-contrast tokens by default (see BaseLayout.astro's own
119
+ --wd-border/--wd-surface light-mode values), so on a page whose own
120
+ background is similarly pale (or, worse, uses the literal same
121
+ image asset as its background - confirmed as the actual root cause
122
+ of a real earlier "the card is invisible" report), the border alone
123
+ can end up nearly imperceptible even though it's genuinely being
124
+ applied. A soft shadow gives the card a second, independent visual
125
+ cue that doesn't depend on border/surface contrast against
126
+ whatever the page happens to look like. */
127
+ .wd-image-figure-framed {
128
+ border: 1px solid var(--wd-border);
129
+ border-radius: 0.75rem;
130
+ background: var(--wd-surface);
131
+ padding: 0.5rem;
132
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
133
+ }
134
+ .wd-image {
135
+ display: block;
136
+ width: 100%;
137
+ height: auto;
138
+ border-radius: 0.75rem;
139
+ }
140
+ .wd-image-dark {
141
+ display: none;
142
+ }
143
+ /* .wd-image-light only hides in dark mode when a dark variant is
144
+ actually there to replace it - .wd-image-has-dark only gets added
145
+ to the figure when srcDark is set (see the frontmatter above); with
146
+ no srcDark, there's no second <img> in the markup at all, so
147
+ unconditionally hiding the light one (an earlier version of this
148
+ rule had no such scoping) left dark mode with literally nothing to
149
+ show - a real user report caught exactly that: light-only Image
150
+ usages went blank in dark mode instead of just keeping the one
151
+ image they had, same as base.css's own dual-logo comment already
152
+ notes for a site that only configures one logo. */
153
+ :global([data-theme="dark"]) .wd-image-figure.wd-image-has-dark .wd-image-light {
154
+ display: none;
155
+ }
156
+ :global([data-theme="dark"]) .wd-image-dark {
157
+ display: block;
158
+ }
159
+ .wd-image-caption {
160
+ margin-top: 0.6rem;
161
+ text-align: center;
162
+ color: var(--wd-text);
163
+ font-size: 0.75rem;
164
+ }
165
+ </style>
@@ -1,67 +1,67 @@
1
- ---
2
- import { extraClasses } from './class-names';
3
- // Mintlify's <Tile> - a visual preview (the slot, usually an image or a
4
- // light/dark image pair) on a patterned background, with a title and
5
- // description under it. Usually laid out in a <Columns> grid. `title`
6
- // takes inline Markdown (`code`, **bold**, *italic*), like Mintlify's.
7
- import { inlineMarkdown } from '../lib/inline-markdown.js';
8
- import { siteHref } from '../lib/site-base';
9
-
10
- interface Props {
11
- href?: string;
12
- title?: string;
13
- description?: string;
14
- }
15
- const { href, title, description } = Astro.props as Props;
16
- const Tag = href ? 'a' : 'div';
17
- ---
18
- <Tag class:list={["wd-tile", extraClasses(Astro.props)]} href={siteHref(href)}>
19
- <div class="wd-tile-preview"><slot /></div>
20
- {title && <div class="wd-tile-title" set:html={inlineMarkdown(title)} />}
21
- {description && <div class="wd-tile-description">{description}</div>}
22
- </Tag>
23
- <style>
24
- .wd-tile {
25
- display: block;
26
- text-decoration: none;
27
- color: inherit;
28
- }
29
- /* Dotted pattern behind the preview, drawn from the theme's own border
30
- color so it reads in both themes. */
31
- .wd-tile-preview {
32
- display: flex;
33
- align-items: center;
34
- justify-content: center;
35
- height: 10rem;
36
- overflow: hidden;
37
- border: 1px solid var(--wd-border);
38
- border-radius: 0.6rem;
39
- background-color: var(--wd-surface);
40
- background-image: radial-gradient(var(--wd-border) 1px, transparent 1px);
41
- background-size: 14px 14px;
42
- transition: border-color 0.15s ease;
43
- }
44
- a.wd-tile:hover .wd-tile-preview {
45
- border-color: var(--wd-primary);
46
- }
47
- .wd-tile-preview :global(img),
48
- .wd-tile-preview :global(svg) {
49
- max-width: 100%;
50
- max-height: 100%;
51
- object-fit: contain;
52
- margin: 0;
53
- }
54
- .wd-tile-preview :global(p) {
55
- display: contents;
56
- }
57
- .wd-tile-title {
58
- margin-top: 0.6rem;
59
- font-weight: 600;
60
- color: var(--wd-heading);
61
- }
62
- .wd-tile-description {
63
- margin-top: 0.15rem;
64
- font-size: 0.875rem;
65
- color: var(--wd-text);
66
- }
67
- </style>
1
+ ---
2
+ import { extraClasses } from './class-names';
3
+ // Mintlify's <Tile> - a visual preview (the slot, usually an image or a
4
+ // light/dark image pair) on a patterned background, with a title and
5
+ // description under it. Usually laid out in a <Columns> grid. `title`
6
+ // takes inline Markdown (`code`, **bold**, *italic*), like Mintlify's.
7
+ import { inlineMarkdown } from '../lib/inline-markdown.js';
8
+ import { siteHref } from '../lib/site-base';
9
+
10
+ interface Props {
11
+ href?: string;
12
+ title?: string;
13
+ description?: string;
14
+ }
15
+ const { href, title, description } = Astro.props as Props;
16
+ const Tag = href ? 'a' : 'div';
17
+ ---
18
+ <Tag class:list={["wd-tile", extraClasses(Astro.props)]} href={siteHref(href)}>
19
+ <div class="wd-tile-preview"><slot /></div>
20
+ {title && <div class="wd-tile-title" set:html={inlineMarkdown(title)} />}
21
+ {description && <div class="wd-tile-description">{description}</div>}
22
+ </Tag>
23
+ <style>
24
+ .wd-tile {
25
+ display: block;
26
+ text-decoration: none;
27
+ color: inherit;
28
+ }
29
+ /* Dotted pattern behind the preview, drawn from the theme's own border
30
+ color so it reads in both themes. */
31
+ .wd-tile-preview {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ height: 10rem;
36
+ overflow: hidden;
37
+ border: 1px solid var(--wd-border);
38
+ border-radius: 0.6rem;
39
+ background-color: var(--wd-surface);
40
+ background-image: radial-gradient(var(--wd-border) 1px, transparent 1px);
41
+ background-size: 14px 14px;
42
+ transition: border-color 0.15s ease;
43
+ }
44
+ a.wd-tile:hover .wd-tile-preview {
45
+ border-color: var(--wd-primary);
46
+ }
47
+ .wd-tile-preview :global(img),
48
+ .wd-tile-preview :global(svg) {
49
+ max-width: 100%;
50
+ max-height: 100%;
51
+ object-fit: contain;
52
+ margin: 0;
53
+ }
54
+ .wd-tile-preview :global(p) {
55
+ display: contents;
56
+ }
57
+ .wd-tile-title {
58
+ margin-top: 0.6rem;
59
+ font-weight: 600;
60
+ color: var(--wd-heading);
61
+ }
62
+ .wd-tile-description {
63
+ margin-top: 0.15rem;
64
+ font-size: 0.875rem;
65
+ color: var(--wd-text);
66
+ }
67
+ </style>