Skip to content

Commit

Permalink
fix meta img tags not working
Browse files Browse the repository at this point in the history
  • Loading branch information
siduck committed Oct 2, 2024
1 parent 10d346c commit 185da3b
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,48 @@ for (const path in routes) {
const moduleMeta = routes[path]?.meta || defaultMeta; // Accessing the meta property of the module

moduleMeta.ogimg = moduleMeta.cover
? moduleMeta.cover.split(".")[0] + '.jpeg'
? moduleMeta.cover.replace("webp", "jpeg")
: defaultMeta.ogimg;

if (!moduleMeta.ogimg.includes("news"))
moduleMeta.ogimg = "/news/" + moduleMeta.ogimg;

metaData[route] = moduleMeta;
}

metaData["/themes/"] = metaData["/themes"];

export default function App() {

return (
<Router
base={import.meta.env.SERVER_BASE_URL}
root={(props) => {

return (
<MetaProvider>
<Title>{metaData[props.location.pathname]?.title}</Title>

<Meta property="og:URL" content="https://www.rankmath.com" />

<Meta
name="description"
content={metaData[props.location.pathname]?.desc}
/>

<Meta name="twitter:card" content="summary_large_image" />

<Meta
name="twitter:image:src"
content={metaData[props.location.pathname]?.ogimg}
/>

<Meta
property="og:image"
content={metaData[props.location.pathname]?.ogimg}
/>

<Navbar pathname={props.location.pathname} />
<Suspense>{props.children}</Suspense>
</MetaProvider>
)}}
return (
<MetaProvider>
<Title>{metaData[props.location.pathname]?.title}</Title>

<Meta property="og:URL" content="https://www.rankmath.com" />

<Meta
name="description"
content={metaData[props.location.pathname]?.desc}
/>

<Meta name="twitter:card" content="summary_large_image" />

<Meta
name="twitter:image:src"
content={metaData[props.location.pathname]?.ogimg}
/>

<Meta
property="og:image"
content={metaData[props.location.pathname]?.ogimg}
/>

<Navbar pathname={props.location.pathname} />
<Suspense>{props.children}</Suspense>
</MetaProvider>
);
}}
>
<FileRoutes />
</Router>
Expand Down

0 comments on commit 185da3b

Please sign in to comment.