feat: useNodeSeo

This commit is contained in:
2026-03-26 14:56:38 -04:00
parent a3122d12c3
commit c9a9e03b60
4 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
fragment NodeSeo on RankMathSeo {
title
description
robots
canonicalUrl
openGraph {
title
description
image {
url
}
}
}

View File

@@ -0,0 +1,14 @@
import type { NodeSeoFragment } from "#graphql/types";
export function useNodeSeo(seo: NodeSeoFragment) {
const { title, description, robots, canonicalUrl, openGraph } = seo;
useSeoMeta({
title,
description,
robots: robots?.join(","),
ogTitle: openGraph?.title,
ogDescription: openGraph?.description,
ogImage: openGraph?.image?.url,
ogUrl: canonicalUrl,
});
}

View File

@@ -4,5 +4,10 @@ query NodeByUri($uri: String!) {
... on Page {
...NodePage
}
... on NodeWithRankMathSeo {
seo @nonNull {
...NodeSeo
}
}
}
}

View File

@@ -28,6 +28,8 @@ if (!useNuxtApp().vueApp.component(componentName)) {
fatal: true,
});
}
useNodeSeo(node.value.seo);
</script>
<template>