uniweb 0.8.11 → 0.8.13

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniweb",
3
- "version": "0.8.11",
3
+ "version": "0.8.13",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,11 +41,11 @@
41
41
  "js-yaml": "^4.1.0",
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.0.0",
44
- "@uniweb/build": "0.8.10",
44
+ "@uniweb/build": "0.8.12",
45
45
  "@uniweb/content-reader": "1.1.4",
46
- "@uniweb/core": "0.5.7",
47
- "@uniweb/runtime": "0.6.7",
48
- "@uniweb/kit": "0.7.7",
49
- "@uniweb/semantic-parser": "1.1.5"
46
+ "@uniweb/core": "0.5.9",
47
+ "@uniweb/kit": "0.7.9",
48
+ "@uniweb/runtime": "0.6.9",
49
+ "@uniweb/semantic-parser": "1.1.6"
50
50
  }
51
51
  }
@@ -172,7 +172,6 @@ content = {
172
172
  title: '', // Main heading (string or string[] for multi-line)
173
173
  pretitle: '', // Heading before main title (auto-detected)
174
174
  subtitle: '', // Heading after title (string or string[] for multi-line)
175
- subtitle2: '', // Third-level heading
176
175
  paragraphs: [], // Text blocks
177
176
  links: [], // { href, label, role } — standalone links become buttons
178
177
  images: [], // { src, alt, role, href }
@@ -183,7 +182,7 @@ content = {
183
182
  quotes: [], // Blockquotes
184
183
  snippets: [], // Fenced code — [{ language, code }]
185
184
  data: {}, // From tagged data blocks (```yaml:tagname, ```json:tagname)
186
- headings: [], // Overflow headings after subtitle2
185
+ headings: [], // Headings after subtitle, in document order
187
186
  items: [], // Each has the same flat structure — from headings after body content
188
187
  sequence: [], // All elements in document order
189
188
  }
@@ -431,6 +430,13 @@ Does the content author write content *inside* the nested element? **Yes** → c
431
430
 
432
431
  Inset components declare `inset: true` in meta.js. Don't use `hidden: true` on insets — `hidden` means "don't export this component at all" (for internal helpers), while `inset: true` means "available for `@Component` references in markdown."
433
432
 
433
+ **What inset components receive:** Insets are full section types — they get `{ content, params, block }` like any other section. The alt text becomes `content.title`, and attributes become `params`:
434
+
435
+ ```markdown
436
+ ![npm create uniweb](@CommandBlock){note="Ready to go"}
437
+ ```
438
+ → CommandBlock receives `content.title = "npm create uniweb"` and `params.note = "Ready to go"`.
439
+
434
440
  **SSG:** Insets, `<ChildBlocks>`, and `<Visual>` all render correctly during prerender. Inset components that use React hooks internally (useState, useEffect) will trigger prerender warnings — this is expected and harmless; the page renders correctly client-side.
435
441
 
436
442
  ### Section Nesting Details
@@ -475,14 +481,12 @@ export default function Grid({ block, params }) {
475
481
 
476
482
  Set `background` in frontmatter — the runtime renders it automatically:
477
483
 
478
- > **FIXME:** var(--primary-900) should be primary-900, right?
479
-
480
484
  ```yaml
481
485
  background: /images/hero.jpg # Image
482
486
  background: /videos/hero.mp4 # Video
483
487
  background: linear-gradient(135deg, #667eea, #764ba2) # Gradient
484
488
  background: '#1a1a2e' # Color (hex — quote in YAML)
485
- background: var(--primary-900) # CSS variable
489
+ background: primary-900 # Palette token (bare name or var())
486
490
  ```
487
491
 
488
492
  Object form for more control:
@@ -603,21 +607,27 @@ Components use **semantic CSS tokens** instead of hardcoded colors. The runtime
603
607
  <h2 className="text-heading">...</h2>
604
608
  ```
605
609
 
606
- **Core tokens** (available as Tailwind classes):
610
+ **Semantic tokens** (available as Tailwind classes — `text-*`, `bg-*`, `border-*`):
607
611
 
608
612
  | Token | Purpose |
609
613
  |-------|---------|
610
- | `text-heading` | Headings |
611
- | `text-body` | Body text |
612
- | `text-subtle` | Secondary/de-emphasized text |
613
- | `bg-section` | Section background |
614
- | `bg-card` | Card/panel background |
615
- | `bg-muted` | Hover states, zebra rows |
616
- | `border-border` | Borders |
617
- | `text-link` | Link color |
618
- | `bg-primary` / `text-primary-foreground` / `hover:bg-primary-hover` | Primary actions |
619
- | `bg-secondary` / `text-secondary-foreground` / `hover:bg-secondary-hover` | Secondary actions |
620
- | `text-success` / `text-error` / `text-warning` / `text-info` | Status colors |
614
+ | `heading` | Heading text |
615
+ | `body` | Body text |
616
+ | `subtle` | Secondary/de-emphasized text |
617
+ | `section` | Section background |
618
+ | `card` | Card/panel/well background |
619
+ | `muted` | Hover states, zebra rows |
620
+ | `border` | Lines, dividers |
621
+ | `ring` | Focus indicators |
622
+ | `link` / `link-hover` | Link colors |
623
+ | `primary` / `primary-foreground` / `primary-hover` / `primary-border` | Primary actions |
624
+ | `secondary` / `secondary-foreground` / `secondary-hover` / `secondary-border` | Secondary actions |
625
+ | `success` / `warning` / `error` / `info` | Status colors |
626
+ | `success-subtle` / `warning-subtle` / `error-subtle` / `info-subtle` | Status backgrounds (alerts) |
627
+
628
+ Use with any Tailwind prefix: `text-heading`, `bg-section`, `border-border`, `bg-primary`, `text-primary-foreground`, `hover:bg-primary-hover`, `bg-error-subtle`, etc.
629
+
630
+ **Palette shades** are also available: `text-primary-600`, `bg-neutral-100`, `border-accent-300` — 11 shades (50–950) for each palette color (primary, secondary, accent, neutral). See `theme-tokens.css` for the complete mapping.
621
631
 
622
632
  **Content authors control context** in frontmatter:
623
633
 
@@ -789,14 +799,16 @@ Content fields are **HTML strings** — they contain `<strong>`, `<em>`, `<a>` f
789
799
  **Extracted fields** (most common — custom layout with content from markdown):
790
800
 
791
801
  ```jsx
792
- import { H1, H2, P, Span } from '@uniweb/kit'
802
+ import { H1, H2, H3, P, Span } from '@uniweb/kit'
793
803
 
794
804
  <H1 text={content.title} className="text-heading text-5xl font-bold" />
805
+ <H2 text={content.subtitle} className="text-heading text-2xl" />
806
+ <H3 text={item.title} className="text-heading text-lg font-semibold" />
795
807
  <P text={content.paragraphs} className="text-body" />
796
808
  <Span text={listItem.paragraphs[0]} className="text-subtle" />
797
809
  ```
798
810
 
799
- These render their own HTML tag — don't wrap: `<H2 text={...} />` not `<h2><H2 text={...} /></h2>`.
811
+ Kit provides `H1` through `H6` — use the appropriate level for semantic hierarchy. These render their own HTML tag — don't wrap: `<H2 text={...} />` not `<h2><H2 text={...} /></h2>`.
800
812
 
801
813
  **Full content rendering** (article/docs sections where the author controls the flow):
802
814
 
@@ -825,18 +837,46 @@ import { Visual } from '@uniweb/kit'
825
837
 
826
838
  **Navigation and routing:** `Link` (`to`/`href`, `to="page:about"` for page ID resolution, auto `target="_blank"` for external, `reload` for full page reload), `useActiveRoute()`, `useWebsite()`, `useRouting()`
827
839
 
828
- **Header and layout:** `useScrolled(threshold)`, `useMobileMenu()`, `useAppearance()` (light/dark mode)
840
+ **Header and layout:** `useScrolled(threshold)`, `useMobileMenu()`, `useAppearance()`
829
841
 
830
842
  **Layout helpers:** `useGridLayout(columns, { gap })`, `useAccordion({ multiple, defaultOpen })`, `useTheme(name)`
831
843
 
832
844
  **Data and theming:** `useThemeData()` (programmatic color access), `useColorContext(block)`
833
845
 
834
- **Utilities:** `cn()` (Tailwind class merge), `Link`, `Image`, `Asset`, `SafeHtml`, `SocialIcon`, `filterSocialLinks(links)`, `getSocialPlatform(url)`
846
+ **Utilities:** `cn()` (Tailwind class merge — `cn('px-4', condition && 'bg-primary')` resolves conflicts), `Link`, `Image`, `Asset`, `SafeHtml`, `SocialIcon`, `filterSocialLinks(links)`, `getSocialPlatform(url)`
835
847
 
836
848
  **Other styled:** `SidebarLayout`, `Prose`, `Article`, `Code`, `Alert`, `Table`, `Details`, `Divider`, `Disclaimer`
837
849
 
850
+ ### Hook Signatures
851
+
852
+ ```js
853
+ useActiveRoute() → { route, rootSegment, isActive(pageOrRoute), isActiveOrAncestor(pageOrRoute) }
854
+ useMobileMenu() → { isOpen, open, close, toggle } // auto-closes on route change
855
+ useScrolled(threshold?) → boolean // true when scrolled past threshold (px)
856
+ useAppearance() → { scheme, setScheme, toggle, canToggle, schemes }
857
+ useWebsite() → { website } // the Website object
858
+ useThemeData() → Theme // programmatic color access
859
+ useColorContext(block) → 'light' | 'medium' | 'dark' // current section context
860
+ ```
861
+
862
+ `isActive` and `isActiveOrAncestor` accept a Page object or a route string. `useAppearance` reads `appearance:` from `theme.yml` — `scheme` is `'light'`|`'dark'`, `canToggle` reflects `allowToggle` config. Stores preference in localStorage, respects system preference.
863
+
864
+ ### Icon Component
865
+
866
+ The `<Icon>` renders icons from content or explicit props. The simplest usage — spread an icon object from content:
867
+
868
+ ```jsx
869
+ {content.icons.map((icon, i) => <Icon key={i} {...icon} />)}
870
+ ```
871
+
872
+ Props: `library` + `name` (from content), `svg` (direct SVG string), `url` (fetch from URL), `size` (default `'24'`), `className`. The legacy `icon` prop accepts shorthand strings (`"lu-house"`) or objects.
873
+
874
+ Built-in icons (no library needed): `check`, `close`, `menu`, `chevronDown`, `chevronRight`, `externalLink`, `download`, `play`, and a few others.
875
+
838
876
  ### Content Patterns for Header and Footer
839
877
 
878
+ Layout sections (`header.md`, `footer.md`) are regular section types — they support the full content shape including tagged data blocks, lists, links, icons, and items. The only difference is they render on every page instead of one.
879
+
840
880
  Header and Footer combine several content categories. Use different parts of the content shape for each role:
841
881
 
842
882
  **Header** — title for logo, list for nav, standalone link for CTA:
@@ -174,7 +174,6 @@ function guaranteeContentStructure(parsedContent) {
174
174
  title: content.title || '',
175
175
  pretitle: content.pretitle || '',
176
176
  subtitle: content.subtitle || '',
177
- subtitle2: content.subtitle2 || '',
178
177
  alignment: content.alignment || null,
179
178
  paragraphs: content.paragraphs || [],
180
179
  links: content.links || [],