feat: useNodeSeo
This commit is contained in:
13
wp-content/themes/headless/app/composables/useNodeSeo.gql
Normal file
13
wp-content/themes/headless/app/composables/useNodeSeo.gql
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
fragment NodeSeo on RankMathSeo {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
robots
|
||||||
|
canonicalUrl
|
||||||
|
openGraph {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
image {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
wp-content/themes/headless/app/composables/useNodeSeo.ts
Normal file
14
wp-content/themes/headless/app/composables/useNodeSeo.ts
Normal 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -4,5 +4,10 @@ query NodeByUri($uri: String!) {
|
|||||||
... on Page {
|
... on Page {
|
||||||
...NodePage
|
...NodePage
|
||||||
}
|
}
|
||||||
|
... on NodeWithRankMathSeo {
|
||||||
|
seo @nonNull {
|
||||||
|
...NodeSeo
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ if (!useNuxtApp().vueApp.component(componentName)) {
|
|||||||
fatal: true,
|
fatal: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useNodeSeo(node.value.seo);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user