@uniweb/runtime 0.2.2 → 0.2.4

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/runtime",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Minimal runtime for loading Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,7 +29,7 @@
29
29
  "node": ">=20.19"
30
30
  },
31
31
  "dependencies": {
32
- "@uniweb/core": "0.1.5"
32
+ "@uniweb/core": "0.1.6"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",
@@ -77,7 +77,7 @@ export default function BlockRenderer({ block, pure = false, extra = {} }) {
77
77
  if (!Component) {
78
78
  return (
79
79
  <div className="block-error" style={{ padding: '1rem', background: '#fef2f2', color: '#dc2626' }}>
80
- Component not found: {block.component}
80
+ Component not found: {block.type}
81
81
  </div>
82
82
  )
83
83
  }
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import React from 'react'
10
+ import { useLocation } from 'react-router-dom'
10
11
  import BlockRenderer from './BlockRenderer.jsx'
11
12
  import Layout from './Layout.jsx'
12
13
  import { useHeadMeta } from '../hooks/useHeadMeta.js'
@@ -35,11 +36,15 @@ export function ChildBlocks({ block, childBlocks, pure = false, extra = {} }) {
35
36
  * - Per-page layout preferences
36
37
  */
37
38
  export default function PageRenderer() {
39
+ const location = useLocation()
38
40
  const uniweb = globalThis.uniweb
39
41
  const website = uniweb?.activeWebsite
40
- const page = website?.activePage
41
42
  const siteName = website?.name || ''
42
43
 
44
+ // Get page from current URL path (not the potentially stale website.activePage)
45
+ // This ensures correct page renders immediately on client-side navigation
46
+ const page = website?.getPage(location.pathname) || website?.activePage
47
+
43
48
  // Get head metadata from page (uses Page.getHeadMeta() if available)
44
49
  const headMeta = page?.getHeadMeta?.() || {
45
50
  title: page?.title || 'Website',
@@ -36,11 +36,14 @@ export function useRememberScroll(options = {}) {
36
36
  const website = uniweb?.activeWebsite
37
37
  if (!website) return
38
38
 
39
- // Get current and previous pages
40
- const currentPage = website.activePage
41
39
  const previousPath = previousPathRef.current
42
40
  const currentPath = location.pathname
43
41
 
42
+ // Sync active page with current route
43
+ // This keeps website.activePage in sync for code that depends on it
44
+ website.setActivePage(currentPath)
45
+ const currentPage = website.activePage
46
+
44
47
  // Skip on first render
45
48
  if (isFirstRender.current) {
46
49
  isFirstRender.current = false