rasengan 1.2.0-beta.0 → 1.2.0-beta.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.2.0-beta.1 (2025-09-19)
4
+
3
5
  ## 1.2.0-beta.0 (2025-09-18)
4
6
 
5
7
  ## 1.1.5 (2025-08-30)
@@ -10,43 +10,38 @@ export default function MetadataProvider({ children, }) {
10
10
  if (typeof window === 'undefined')
11
11
  return;
12
12
  (async () => {
13
- const loadersData = routes.map((route) => route.loaderData);
14
- await handleApplyMetadata(loadersData);
13
+ const loadersData = routes.map((route) => route.loaderData ?? route.data // Normally the route.data is deprecated, we need to consider route.loaderData, but in some cases, it's undefined and I don't know why, that's why we are using route.data instead
14
+ );
15
+ handleInjectMetadata(loadersData);
15
16
  })();
16
17
  }, [location]);
17
- const handleApplyMetadata = async (loadersData) => {
18
+ const handleInjectMetadata = (loadersData) => {
18
19
  // We generate the metadata
19
20
  const metadatas = generateMetadata(loadersData.map((item) => item.meta));
20
21
  // We get the last metadata
21
22
  // This is the metadata of the page
22
23
  const leafMetadata = loadersData.at(-1)?.meta;
23
- handleInjectMetadata(metadatas, leafMetadata);
24
- };
25
- const handleInjectMetadata = (metaTags, leafMetadata) => {
26
- // Check if we are on the browser
27
- if (typeof window !== 'undefined') {
28
- // Find all meta tags with data-rg attribute and remove them
29
- const metaTagsToRemove = document.querySelectorAll('meta[data-rg="true"]');
30
- metaTagsToRemove.forEach((metaTag) => {
31
- metaTag.remove();
32
- });
33
- // Inject the meta tags
34
- metaTags.forEach((metaTag) => {
35
- // Convert React element to string
36
- const metaTagString = ReactDOMServer.renderToStaticMarkup(metaTag);
37
- document.head.insertAdjacentHTML('beforeend', metaTagString);
38
- });
39
- if (!leafMetadata)
40
- return;
41
- // Change the title of the page
42
- document.title = leafMetadata.title;
43
- // Change the description of the page
44
- const metaDescription = document.createElement('meta');
45
- metaDescription.setAttribute('name', 'description');
46
- metaDescription.setAttribute('content', leafMetadata.description);
47
- metaDescription.setAttribute('data-rg', 'true');
48
- document.head.appendChild(metaDescription);
49
- }
24
+ // Find all meta tags with data-rg attribute and remove them
25
+ const metaTagsToRemove = document.querySelectorAll('meta[data-rg="true"]');
26
+ metaTagsToRemove.forEach((metaTag) => {
27
+ metaTag.remove();
28
+ });
29
+ // Inject the meta tags
30
+ metadatas.forEach((metaTag) => {
31
+ // Convert React element to string
32
+ const metaTagString = ReactDOMServer.renderToStaticMarkup(metaTag);
33
+ document.head.insertAdjacentHTML('beforeend', metaTagString);
34
+ });
35
+ if (!leafMetadata)
36
+ return;
37
+ // Change the title of the page
38
+ document.title = leafMetadata.title;
39
+ // Change the description of the page
40
+ const metaDescription = document.createElement('meta');
41
+ metaDescription.setAttribute('name', 'description');
42
+ metaDescription.setAttribute('content', leafMetadata.description);
43
+ metaDescription.setAttribute('data-rg', 'true');
44
+ document.head.appendChild(metaDescription);
50
45
  };
51
46
  return _jsx(_Fragment, { children: children });
52
47
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.2.0-beta.0",
4
+ "version": "1.2.0-beta.1",
5
5
  "description": "The modern React Framework",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",