@uniweb/runtime 0.2.3 → 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
|
@@ -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
|