routerino 1.0.1 → 1.0.2
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/dist/routerino.js +4 -1
- package/dist/routerino.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/routerino.js
CHANGED
|
@@ -36,7 +36,10 @@ function y({
|
|
|
36
36
|
if (t) {
|
|
37
37
|
if (t.title) {
|
|
38
38
|
const i = `${t.titlePrefix ?? u}${t.title}${t.titlePostfix ?? f}`;
|
|
39
|
-
document.title = i, o({
|
|
39
|
+
document.title = i, o({
|
|
40
|
+
property: "og:title",
|
|
41
|
+
content: `${t.title}${!!t.description && ` - ${t.description}`}`
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
return t.description && (o({ name: "description", content: t.description }), o({
|
|
42
45
|
property: "og:description",
|
package/dist/routerino.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e(require("react/jsx-runtime"),require("prop-types")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","prop-types"],e):(t=typeof globalThis<"u"?globalThis:t||self,t.routerino=e(t["react/jsx-runtime"],t.PropTypes))})(this,function(t,e){"use strict";function o({tag:s="meta",...l}){const
|
|
1
|
+
(function(t,e){typeof exports=="object"&&typeof module<"u"?module.exports=e(require("react/jsx-runtime"),require("prop-types")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","prop-types"],e):(t=typeof globalThis<"u"?globalThis:t||self,t.routerino=e(t["react/jsx-runtime"],t.PropTypes))})(this,function(t,e){"use strict";function o({tag:s="meta",...l}){const a=Object.keys(l);if(a.length<1)return console.error(`updateHeadTag() received no attributes to set for ${s} tag`);let d=null;for(let i=0;i<a.length&&(a[i]!=="content"&&(d=document.querySelector(`${s}[${a[i]}='${l[a[i]]}']`)),!d);i++);d||(d=document.createElement(s)),Object.keys(l).forEach(i=>d.setAttribute(i,l[i])),document.querySelector("head").appendChild(d)}function p({routes:s,notFoundTemplate:l,notFoundTitle:a,errorTemplate:d,errorTitle:i,useTrailingSlash:m,usePrerenderTags:f,titlePrefix:u,titlePostfix:h}){var g;try{let r=((g=window==null?void 0:window.location)==null?void 0:g.pathname)??"/";r==="/index.html"&&(r="/");const x=s.find(c=>c.path===r),b=s.find(c=>`${c.path}/`===r||c.path===`${r}/`),n=x??b;if(n){if(n.title){const c=`${n.titlePrefix??u}${n.title}${n.titlePostfix??h}`;document.title=c,o({property:"og:title",content:`${n.title}${!!n.description&&` - ${n.description}`}`})}return n.description&&(o({name:"description",content:n.description}),o({property:"og:description",content:n.description})),f&&(m&&!r.endsWith("/")?(o({name:"prerender-status-code",content:"301"}),o({name:"prerender-header",content:`Location: ${window.location.href}/`})):!m&&r.endsWith("/")&&(o({name:"prerender-status-code",content:"301"}),o({name:"prerender-header",content:`Location: ${window.location.href.slice(0,-1)}`}))),n.tags&&n.tags.length?(n.tags.find(({property:c})=>c==="og:type")||o({property:"og:type",content:"website"}),n.tags.forEach(c=>o(c))):o({property:"og:type",content:"website"}),n.element?n.element:(console.error(`No element found for ${r}`),document.title=`${u}${a}${h}`,f&&o({name:"prerender-status-code",content:"404"}),l)}return console.error(`No route found for ${r}`),document.title=`${u}${a}${h}`,f&&o({name:"prerender-status-code",content:"404"}),l}catch(r){return console.error(`Routerino error: ${r}`),f&&o({name:"prerender-status-code",content:"500"}),document.title=`${u}${i}${h}`,d}}p.defaultProps={routes:[{path:"/",element:t.jsx("p",{children:"This is the default route. Pass an array of routes to the Routerino component in order to configure your own pages."}),description:"The default route example description.",tags:[{property:"og:locale",content:"en_US"}]}],notFoundTemplate:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"No page found for this URL. [404]"}),t.jsx("p",{children:t.jsx("a",{href:"/",children:"Home"})})]}),notFoundTitle:"Page not found [404]",errorTemplate:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Page failed to load. [500]"}),t.jsx("p",{children:t.jsx("a",{href:"/",children:"Home"})})]}),errorTitle:"Page error [500]",useTrailingSlash:!0,usePrerenderTags:!0,titlePrefix:"",titlePostfix:""};const $=e.exact({path:e.string.isRequired,element:e.element.isRequired,title:e.string,description:e.string,tags:e.arrayOf(e.object),titlePrefix:e.string,titlePostfix:e.string});return p.propTypes={routes:e.arrayOf($),notFoundTemplate:e.element,notFoundTitle:e.string,errorTemplate:e.element,errorTitle:e.string,useTrailingSlash:e.bool,usePrerenderTags:e.bool,titlePrefix:e.string,titlePostfix:e.string},p});
|