@jaamd/jaad 0.11.0 → 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 (138) hide show
  1. package/README.md +8 -2
  2. package/dist/jaad.css +232 -347
  3. package/docs/00-overview.md +25 -0
  4. package/docs/01-getting-started/01-installation.md +216 -0
  5. package/docs/01-getting-started/02-pages.md +109 -0
  6. package/docs/01-getting-started/03-deployment.md +100 -0
  7. package/docs/02-configurations/01-reference.md +215 -0
  8. package/docs/02-configurations/02-frontmatter.md +105 -0
  9. package/docs/02-configurations/03-i18n.md +210 -0
  10. package/docs/02-configurations/04-search.md +58 -0
  11. package/docs/02-configurations/05-themes.md +104 -0
  12. package/docs/02-configurations/06-styles.md +156 -0
  13. package/docs/02-configurations/07-custom-pages.md +119 -0
  14. package/docs/02-configurations/08-advanced-layout.md +139 -0
  15. package/docs/03-upgrading.md +208 -0
  16. package/index.ts +8 -22
  17. package/package.json +10 -9
  18. package/site.ts +18 -1
  19. package/src/config.ts +25 -176
  20. package/src/{advanced.ts → docs/advanced.ts} +6 -4
  21. package/src/docs/collection.ts +109 -0
  22. package/src/docs/components/Breadcrumbs.astro +29 -0
  23. package/src/docs/components/DocsMobileNav.astro +90 -0
  24. package/src/docs/components/DocsNavTree.astro +57 -0
  25. package/src/docs/components/DocsPage.astro +66 -0
  26. package/src/{components/docs → docs/components}/DocsPageNav.astro +4 -4
  27. package/src/docs/components/DocsSidebarLeft.astro +53 -0
  28. package/src/{components/docs → docs/components}/PageActions.astro +10 -8
  29. package/src/{components/docs → docs/components}/StructuredData.astro +3 -3
  30. package/src/{components/docs → docs/components}/TableOfContents.astro +20 -22
  31. package/src/docs/config.ts +167 -0
  32. package/src/docs/content.ts +36 -0
  33. package/src/docs/endpoints.ts +89 -0
  34. package/src/docs/integration.ts +249 -0
  35. package/src/{layouts → docs/layouts}/DefaultDocsFrame.astro +7 -5
  36. package/src/{layouts → docs/layouts}/Docs.astro +44 -43
  37. package/src/docs/layouts/Page.astro +18 -0
  38. package/src/docs/link-plugins.ts +52 -0
  39. package/src/docs/links.ts +42 -0
  40. package/src/{locale-tree.ts → docs/locale-tree.ts} +1 -1
  41. package/src/docs/model/ids.ts +87 -0
  42. package/src/docs/model/rendered.ts +185 -0
  43. package/src/docs/model/tree.ts +124 -0
  44. package/src/docs/model/validate.ts +75 -0
  45. package/src/docs/navigation.ts +75 -0
  46. package/src/{routes → docs/routes}/404.astro +1 -1
  47. package/src/docs/routes/docs-index.astro +19 -0
  48. package/src/docs/routes/docs-slug.astro +54 -0
  49. package/src/{routes → docs/routes}/docs-slug.md.ts +8 -10
  50. package/src/{routes → docs/routes}/llms-locale.txt.ts +1 -1
  51. package/src/{routes → docs/routes}/llms.txt.ts +1 -1
  52. package/src/{routes → docs/routes}/search-index-locale.json.ts +1 -1
  53. package/src/{routes → docs/routes}/search-index.json.ts +1 -1
  54. package/src/docs/runtime.ts +17 -0
  55. package/src/docs/search-index.ts +39 -0
  56. package/src/docs/styles/components/breadcrumbs.css +26 -0
  57. package/src/docs/styles/components/docs-mobile-nav.css +47 -0
  58. package/src/docs/styles/components/docs-page-nav.css +41 -0
  59. package/src/docs/styles/components/docs-sidebar.css +59 -0
  60. package/src/docs/styles/components/page-actions.css +51 -0
  61. package/src/docs/styles/components/toc.css +38 -0
  62. package/src/docs/styles/components.css +7 -0
  63. package/src/docs/styles/docs.css +81 -0
  64. package/src/{@types/docs.ts → docs/types.ts} +8 -16
  65. package/src/{urls.ts → docs/urls.ts} +2 -16
  66. package/src/env.d.ts +1 -1
  67. package/src/integration.ts +15 -249
  68. package/src/{components → site/components}/Footer.astro +1 -1
  69. package/src/{components → site/components}/Header.astro +14 -11
  70. package/src/{components → site/components}/LocaleSwitcher.astro +2 -2
  71. package/src/{components → site/components}/NavMobile.astro +1 -1
  72. package/src/{components → site/components}/SearchPalette.astro +160 -79
  73. package/src/{components → site/components}/ThemeSwitcher.astro +1 -1
  74. package/src/site/config.ts +149 -0
  75. package/src/{infer.ts → site/infer.ts} +3 -3
  76. package/src/site/integration.ts +59 -0
  77. package/src/{layouts/Page.astro → site/layouts/Shell.astro} +6 -3
  78. package/src/{locales.ts → site/locales.ts} +9 -1
  79. package/src/{docs-config.ts → site/runtime.ts} +1 -12
  80. package/src/site/search.ts +227 -0
  81. package/src/{social.ts → site/social.ts} +2 -2
  82. package/src/site/styles/components/header.css +31 -0
  83. package/src/{styles → site/styles}/components/search.css +21 -1
  84. package/src/{styles → site/styles}/components/shell.css +4 -0
  85. package/src/site/styles/components.css +10 -0
  86. package/src/{styles → site/styles}/global.css +4 -26
  87. package/src/{themes/index.ts → site/themes.ts} +1 -1
  88. package/src/{ui → site/ui}/en.ts +3 -5
  89. package/src/{ui → site/ui}/it.ts +2 -4
  90. package/src/site/urls.ts +14 -0
  91. package/src/{virtual.ts → site/virtual.ts} +12 -18
  92. package/src/styles.css +5 -0
  93. package/src/collection.ts +0 -97
  94. package/src/components/ScrollToTop.astro +0 -43
  95. package/src/components/docs/Breadcrumbs.astro +0 -36
  96. package/src/components/docs/DocsMobileNav.astro +0 -93
  97. package/src/components/docs/DocsPage.astro +0 -68
  98. package/src/components/docs/DocsSidebarLeft.astro +0 -82
  99. package/src/content.ts +0 -42
  100. package/src/navigation.ts +0 -97
  101. package/src/routes/docs-index.astro +0 -19
  102. package/src/routes/docs-slug.astro +0 -58
  103. package/src/styles/components/breadcrumbs.css +0 -13
  104. package/src/styles/components/docs-mobile-nav.css +0 -9
  105. package/src/styles/components/docs-page-nav.css +0 -31
  106. package/src/styles/components/docs-sidebar.css +0 -42
  107. package/src/styles/components/header.css +0 -20
  108. package/src/styles/components/page-actions.css +0 -13
  109. package/src/styles/components/scroll-to-top.css +0 -11
  110. package/src/styles/components/toc.css +0 -21
  111. package/src/styles/docs.css +0 -112
  112. package/src/utils/docs.ts +0 -300
  113. package/src/utils/endpoints.ts +0 -80
  114. package/src/utils/search.ts +0 -83
  115. /package/src/{styles → docs/styles}/components/docs-page.css +0 -0
  116. /package/src/{styles → docs/styles}/jaamd.css +0 -0
  117. /package/src/{components → site/components}/Head.astro +0 -0
  118. /package/src/{components → site/components}/Nav.astro +0 -0
  119. /package/src/{components → site/components}/SocialLinks.astro +0 -0
  120. /package/src/{components → site/components}/locale-switcher.ts +0 -0
  121. /package/src/{fonts → site/fonts}/OFL.txt +0 -0
  122. /package/src/{fonts → site/fonts}/inter.woff2 +0 -0
  123. /package/src/{fonts → site/fonts}/merriweather-italic.woff2 +0 -0
  124. /package/src/{fonts → site/fonts}/merriweather.woff2 +0 -0
  125. /package/src/{fonts.ts → site/fonts.ts} +0 -0
  126. /package/src/{forges.ts → site/forges.ts} +0 -0
  127. /package/src/{utils → site}/helpers.ts +0 -0
  128. /package/src/{styles → site/styles}/components/footer.css +0 -0
  129. /package/src/{styles → site/styles}/components/locale-switcher.css +0 -0
  130. /package/src/{styles → site/styles}/components/nav-mobile.css +0 -0
  131. /package/src/{styles → site/styles}/components/nav.css +0 -0
  132. /package/src/{styles → site/styles}/components/not-found.css +0 -0
  133. /package/src/{styles → site/styles}/components/social-links.css +0 -0
  134. /package/src/{styles → site/styles}/components/theme-switcher.css +0 -0
  135. /package/src/{styles → site/styles}/jaamd-forward.css +0 -0
  136. /package/src/{styles → site/styles}/jaamd-reverse.css +0 -0
  137. /package/src/{styles → site/styles}/tailwind.css +0 -0
  138. /package/src/{ui.ts → site/ui.ts} +0 -0
@@ -0,0 +1,26 @@
1
+ @layer components {
2
+ .docs-breadcrumbs {
3
+ display: flex;
4
+ flex-wrap: wrap;
5
+ gap: 0.375rem;
6
+ margin-bottom: 0.5rem;
7
+ font-size: 0.8125rem;
8
+ color: var(--color-foreground-muted);
9
+ }
10
+
11
+ .docs-breadcrumbs-link {
12
+ color: inherit;
13
+ text-decoration: none;
14
+ }
15
+
16
+ .docs-breadcrumbs-link:hover {
17
+ color: var(--color-foreground-bright);
18
+ }
19
+
20
+ /* Narrow, the navigation menu above already names them. */
21
+ @media (width < 64rem) {
22
+ [data-jaad-default-frame] .docs-breadcrumbs {
23
+ display: none;
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,47 @@
1
+ @layer components {
2
+ .docs-mobile-nav {
3
+ margin-bottom: 1.5rem;
4
+ border-top: 1px solid var(--color-border);
5
+ font-size: 0.875rem;
6
+ }
7
+
8
+ .docs-mobile-menu {
9
+ border-bottom: 1px solid var(--color-border);
10
+ }
11
+
12
+ .docs-mobile-summary {
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ align-items: center;
16
+ gap: 0.375rem;
17
+ min-height: 2.75rem;
18
+ color: var(--color-foreground-muted);
19
+ cursor: pointer;
20
+ list-style: none;
21
+ }
22
+
23
+ .docs-mobile-summary::-webkit-details-marker {
24
+ display: none;
25
+ }
26
+
27
+ .docs-mobile-icon {
28
+ width: 1rem;
29
+ height: 1rem;
30
+ margin-right: 0.25rem;
31
+ }
32
+
33
+ .docs-mobile-current {
34
+ color: var(--color-foreground-bright);
35
+ font-weight: 500;
36
+ }
37
+
38
+ .docs-mobile-tree {
39
+ padding: 0.25rem 0 1rem 0.75rem;
40
+ }
41
+
42
+ @media (min-width: 64rem) {
43
+ .docs-mobile-nav {
44
+ display: none;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,41 @@
1
+ @layer components {
2
+ .docs-page-nav {
3
+ margin-top: 3rem;
4
+ padding-top: 0.5rem;
5
+ border-top: 1px solid var(--color-border);
6
+ }
7
+
8
+ .docs-page-nav-row {
9
+ display: flex;
10
+ justify-content: space-between;
11
+ gap: 1rem;
12
+ }
13
+
14
+ .docs-page-nav-link {
15
+ display: flex;
16
+ align-items: center;
17
+ gap: 0.5rem;
18
+ min-width: 0;
19
+ max-width: calc(50% - 0.5rem);
20
+ min-height: 2.75rem;
21
+ color: var(--color-foreground-bright);
22
+ font-size: 0.875rem;
23
+ text-decoration: none;
24
+ }
25
+
26
+ .docs-page-nav-link:hover {
27
+ color: var(--color-foreground-muted);
28
+ }
29
+
30
+ .docs-page-nav-icon {
31
+ flex: none;
32
+ width: 1rem;
33
+ height: 1rem;
34
+ }
35
+
36
+ .docs-page-nav-label {
37
+ overflow: hidden;
38
+ text-overflow: ellipsis;
39
+ white-space: nowrap;
40
+ }
41
+ }
@@ -0,0 +1,59 @@
1
+ @layer components {
2
+ .docs-sidebar-left nav {
3
+ font-size: 0.875rem;
4
+ line-height: 1.5;
5
+ }
6
+
7
+ .docs-sidebar-list {
8
+ margin: 0;
9
+ padding: 0;
10
+ list-style: none;
11
+ }
12
+
13
+ /* The bar of the current page sits in the gutter, so every label lines up. */
14
+ .docs-sidebar-link {
15
+ display: block;
16
+ margin-left: -0.75rem;
17
+ padding: 0.25rem 0 0.25rem calc(0.75rem - 2px);
18
+ border-left: 2px solid transparent;
19
+ color: var(--color-foreground);
20
+ text-decoration: none;
21
+ }
22
+
23
+ .docs-sidebar-link:hover {
24
+ color: var(--color-foreground-bright);
25
+ }
26
+
27
+ .docs-sidebar-link[aria-current='page'] {
28
+ border-color: var(--color-foreground-bright);
29
+ color: var(--color-foreground-bright);
30
+ font-weight: 500;
31
+ }
32
+
33
+ .docs-sidebar-chapter {
34
+ margin-top: 1rem;
35
+ }
36
+
37
+ .docs-sidebar-chapter + li:not(.docs-sidebar-chapter) {
38
+ margin-top: 1rem;
39
+ }
40
+
41
+ .docs-sidebar-chapter-title {
42
+ margin: 0 0 0.25rem;
43
+ font-size: 0.75rem;
44
+ font-weight: 500;
45
+ color: var(--color-foreground-muted);
46
+ }
47
+
48
+ .docs-sidebar-section {
49
+ margin-top: 1rem;
50
+ padding-top: 0.75rem;
51
+ border-top: 1px solid var(--color-border);
52
+ }
53
+
54
+ .docs-sidebar-section-title {
55
+ margin: 0 0 0.25rem;
56
+ color: var(--color-foreground-bright);
57
+ font-weight: 600;
58
+ }
59
+ }
@@ -0,0 +1,51 @@
1
+ @layer components {
2
+ .docs-page-actions {
3
+ display: flex;
4
+ flex-wrap: wrap;
5
+ gap: 0.25rem 1.25rem;
6
+ margin-top: 2rem;
7
+ font-size: 0.8125rem;
8
+ }
9
+
10
+ .docs-page-action {
11
+ display: flex;
12
+ align-items: center;
13
+ gap: 0.5rem;
14
+ min-height: 2.75rem;
15
+ padding: 0;
16
+ border: 0;
17
+ background: none;
18
+ color: var(--color-foreground-muted);
19
+ font: inherit;
20
+ text-decoration: none;
21
+ cursor: pointer;
22
+ }
23
+
24
+ .docs-page-action:hover {
25
+ color: var(--color-foreground-bright);
26
+ }
27
+
28
+ .docs-page-action-icon {
29
+ flex: none;
30
+ width: 0.875rem;
31
+ height: 0.875rem;
32
+ }
33
+
34
+ /* Under the table of contents: a column of quiet links. */
35
+ @media (min-width: 64rem) {
36
+ .docs-page-actions {
37
+ flex-direction: column;
38
+ margin-top: 0;
39
+ }
40
+
41
+ .docs-page-action {
42
+ min-height: 1.75rem;
43
+ }
44
+
45
+ .docs-toc ~ .docs-page-actions {
46
+ margin-top: 1.5rem;
47
+ padding-top: 1rem;
48
+ border-top: 1px solid var(--color-border);
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,38 @@
1
+ @layer components {
2
+ .docs-toc-title {
3
+ margin: 0 0 0.5rem;
4
+ font-family: var(--font-sans);
5
+ font-size: 0.75rem;
6
+ font-weight: 500;
7
+ color: var(--color-foreground-muted);
8
+ }
9
+
10
+ .docs-toc-list {
11
+ margin: 0;
12
+ padding: 0;
13
+ list-style: none;
14
+ }
15
+
16
+ .docs-toc-link {
17
+ display: block;
18
+ padding: 0.1875rem 0 0.1875rem calc(0.625rem - 2px);
19
+ border-left: 2px solid transparent;
20
+ color: var(--color-foreground-muted);
21
+ font-size: 0.8125rem;
22
+ line-height: 1.5;
23
+ text-decoration: none;
24
+ }
25
+
26
+ .docs-toc-link-nested {
27
+ padding-left: calc(1.375rem - 2px);
28
+ }
29
+
30
+ .docs-toc-link:hover {
31
+ color: var(--color-foreground-bright);
32
+ }
33
+
34
+ .docs-toc-link[aria-current='location'] {
35
+ border-color: var(--color-foreground-bright);
36
+ color: var(--color-foreground-bright);
37
+ }
38
+ }
@@ -0,0 +1,7 @@
1
+ @import './components/docs-page.css';
2
+ @import './components/docs-sidebar.css';
3
+ @import './components/toc.css';
4
+ @import './components/docs-mobile-nav.css';
5
+ @import './components/docs-page-nav.css';
6
+ @import './components/page-actions.css';
7
+ @import './components/breadcrumbs.css';
@@ -0,0 +1,81 @@
1
+ /* Layered, so a page's own utilities still win. */
2
+ @layer components {
3
+ .docs-frame {
4
+ display: contents;
5
+ }
6
+
7
+ /* The header's column. Wide, it holds the page between two sidebars fixed
8
+ to the window: only the page scrolls. */
9
+ .docs-container {
10
+ width: 100%;
11
+ max-width: var(--jaad-chrome-width);
12
+ margin-inline: auto;
13
+ padding-inline: 1rem;
14
+ }
15
+
16
+ .docs-main {
17
+ width: 100%;
18
+ min-width: 0;
19
+ max-width: var(--jaad-content-width);
20
+ margin-inline: auto;
21
+ }
22
+
23
+ .docs-page-main {
24
+ padding-top: 2rem;
25
+ }
26
+
27
+ [data-jaad-default-frame] .docs-container > .jaad-footer {
28
+ width: 100%;
29
+ max-width: var(--jaad-content-width);
30
+ margin-inline: auto;
31
+ }
32
+
33
+ @media (48rem <= width < 64rem) {
34
+ .docs-page-main {
35
+ padding-inline: var(--jaad-page-padding);
36
+ }
37
+ }
38
+
39
+ @media (min-width: 64rem) {
40
+ .docs-page-main {
41
+ padding-top: 2.5rem;
42
+ }
43
+
44
+ [data-jaad-default-frame] .docs-container {
45
+ display: grid;
46
+ grid-template-columns: var(--jaad-sidebar-width) minmax(0, 1fr) var(--jaad-sidebar-width);
47
+ column-gap: 3rem;
48
+ }
49
+
50
+ [data-jaad-default-frame] .docs-main,
51
+ [data-jaad-default-frame] .docs-container > .jaad-footer {
52
+ grid-column: 2;
53
+ }
54
+
55
+ [data-jaad-default-frame] .docs-sidebar-left,
56
+ [data-jaad-default-frame] .docs-sidebar-right {
57
+ position: fixed;
58
+ top: var(--jaad-header-height);
59
+ bottom: 0;
60
+ padding-block: 2rem;
61
+ }
62
+
63
+ /* Widened into the gutter, where the bar of the current page sits. */
64
+ [data-jaad-default-frame] .docs-sidebar-left {
65
+ left: max(1rem, calc(50% - var(--jaad-chrome-width) / 2 + 1rem));
66
+ margin-left: -0.75rem;
67
+ padding-left: 0.75rem;
68
+ }
69
+
70
+ [data-jaad-default-frame] .docs-sidebar-right {
71
+ right: max(1rem, calc(50% - var(--jaad-chrome-width) / 2 + 1rem));
72
+ }
73
+ }
74
+
75
+ @media (width < 64rem) {
76
+ [data-jaad-default-frame] .docs-sidebar-left,
77
+ [data-jaad-default-frame] .docs-sidebar-right .docs-toc {
78
+ display: none;
79
+ }
80
+ }
81
+ }
@@ -1,20 +1,15 @@
1
- export interface ParsedDocsCollectionId {
2
- slug: string
3
- orderChapter?: number
4
- chapter?: string
5
- order: number
6
- title: string
7
- }
1
+ import type { RenderedMarkdown } from './model/rendered.ts'
8
2
 
9
3
  export interface DocsNavItem {
10
4
  title: string
11
- chapter: string | undefined
12
- primaryOrder: number
5
+ /** Set when the docs are split into sections. */
6
+ section?: string
7
+ chapter?: string
13
8
  href: string
14
9
  isActive: boolean
15
10
  }
16
11
 
17
- export interface DocsHeadings {
12
+ export interface DocsHeading {
18
13
  depth: 2 | 3
19
14
  slug: string
20
15
  text: string
@@ -34,14 +29,11 @@ export interface DocsPageData {
34
29
  lastUpdated?: Date
35
30
  }
36
31
 
37
- /** The shape jaad requires of the docs collection. Astro generates collection
38
- * types in the consumer project, so the package states its own contract. */
32
+ /** The shape jaad requires of a docs collection entry. Astro generates
33
+ * collection types in the consumer project, so the package states its own contract. */
39
34
  export interface DocsEntry {
40
35
  id: string
41
- /** Set when the docs are localised; the id without its locale directory. */
42
- localeId?: string
43
- /** Set when the docs are localised. */
44
- locale?: string
45
36
  body?: string
46
37
  data: DocsPageData
38
+ rendered?: RenderedMarkdown
47
39
  }
@@ -1,19 +1,5 @@
1
- import { localeSegment } from './locales.ts'
2
-
3
- /** Empty at the site root, otherwise one leading slash and no trailing slash. */
4
- export function normaliseBasePath(value: string): string {
5
- const trimmed = value.replace(/^\/+/, '').replace(/\/+$/, '')
6
- return trimmed ? `/${trimmed}` : ''
7
- }
8
-
9
- /** Apply Astro's deployment base to an application-local, root-relative href. */
10
- export function withDeploymentBase(href: string, deploymentBase: string): string {
11
- if (!href.startsWith('/') || href.startsWith('//')) return href
12
-
13
- const prefix = normaliseBasePath(deploymentBase)
14
- if (!prefix) return href
15
- return href === '/' ? `${prefix}/` : `${prefix}${href}`
16
- }
1
+ import { localeSegment } from '../site/locales.ts'
2
+ import { normaliseBasePath, withDeploymentBase } from '../site/urls.ts'
17
3
 
18
4
  export interface DocsUrlOptions {
19
5
  /** routeBase, normalised here: empty at the application root. */
package/src/env.d.ts CHANGED
@@ -8,6 +8,6 @@ declare module 'virtual:jaad/config' {
8
8
 
9
9
  declare module 'virtual:jaad/docs-frame' {
10
10
  // oxlint-disable-next-line typescript/consistent-type-imports
11
- const DocsFrame: typeof import('./layouts/DefaultDocsFrame.astro').default
11
+ const DocsFrame: typeof import('./docs/layouts/DefaultDocsFrame.astro').default
12
12
  export default DocsFrame
13
13
  }