vue
Setup Schema.org with your îles app.
yarn add -D @unhead/schema-org-vue
Start by adding in the îles Schema.org module which handles component auto-imports.
import { defineConfig } from 'iles'
import { SchemaOrgResolver } from '@unhead/schema-org-vue'
export default defineConfig({
siteUrl: 'https://iles-docs.netlify.app/',
modules: [
{
name: '@unhead/schema-org-vue',
components: {
resolvers: [
// adds component auto-imports
SchemaOrgResolver(),
],
},
},
],
})
Note: Make sure you set your siteUrl
if you haven't already.
Add the vue plugin in your app.ts
file.
import { defineApp } from 'iles'
import { SchemaOrgUnheadPlugin } from '@unhead/schema-org-vue'
export default defineApp({
async enhanceApp(ctx) {
ctx.head.use(SchemaOrgUnheadPlugin({
// user config
host: ctx.site.url,
// needed for iles
tagPosition: 'head',
}, () => {
// adds meta for runtime inferences
return {
path: ctx.router?.currentRoute.value.path || '/',
...ctx.meta,
...ctx.frontmatter,
...ctx.router?.currentRoute.value.meta || {},
}
}))
},
})
See the User Config page for all options you can pass.
Within your layouts/default.vue
file you can add your site-wide schema.
<script lang="ts" setup>
import { defineWebPage, defineWebSite, useSchemaOrg } from '@unhead/schema-org-vue'
useSchemaOrg([
defineWebPage(),
defineWebSite({
name: 'test',
}),
])
</script>
Your îles app is now serving basic Schema.org, congrats! 🎉
The next steps are: