Skip to content

Commit 74d8acc

Browse files
committed
seo fixes
1 parent 618db93 commit 74d8acc

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

src/components/Recipe.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ export default {
197197
.filter(Boolean)
198198
.map((text, i) => ({ '@type': 'HowToStep', position: i + 1, text }))
199199
: [];
200+
const drinkKeywords = Array.isArray(this.drink.keywords)
201+
? this.drink.keywords.map(k => k.toLowerCase())
202+
: [];
203+
const getRecipeCategory = () => {
204+
if (drinkKeywords.includes('alcoholic')) return 'Cocktail';
205+
if (drinkKeywords.includes('smoothie')) return 'Smoothie';
206+
if (drinkKeywords.includes('coffee')) return 'Coffee Drink';
207+
if (drinkKeywords.includes('tea')) return 'Tea';
208+
if (drinkKeywords.includes('juice')) return 'Juice';
209+
return 'Drink';
210+
};
211+
const imageUrl = this.drink.img ? `https://opendrinks.io${this.drink.img}` : undefined;
200212
return {
201213
title: metaTitle,
202214
titleTemplate: title => `${title} | Open Drinks`,
@@ -208,11 +220,11 @@ export default {
208220
{ property: 'og:site_name', content: 'Open Drinks' },
209221
{ property: 'og:url', content: `https://opendrinks.io${window.location.pathname}` },
210222
{ property: 'og:description', content: metaDescription },
211-
{ property: 'og:image', content: `https://opendrinks.io${this.drink.img}` },
223+
{ property: 'og:image', content: imageUrl },
212224
{ property: 'og:image:alt', content: this.drink.name },
213225
{ itemprop: 'name', content: this.drink.name },
214226
{ itemprop: 'description', content: metaDescription },
215-
{ itemprop: 'image', content: `https://opendrinks.io${this.drink.img}` },
227+
{ itemprop: 'image', content: imageUrl },
216228
],
217229
script: [
218230
{
@@ -223,9 +235,10 @@ export default {
223235
name: this.drink.name,
224236
url: `https://opendrinks.io${window.location.pathname}`,
225237
description: metaDescription,
226-
image: `https://opendrinks.io${this.drink.img}`,
238+
image: imageUrl ? [imageUrl] : undefined,
227239
recipeIngredient,
228240
recipeInstructions,
241+
recipeCategory: getRecipeCategory(),
229242
keywords: Array.isArray(this.drink.keywords)
230243
? this.drink.keywords.join(', ')
231244
: undefined,

src/main.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import 'bootstrap-icons/font/bootstrap-icons.css';
33
import 'bootstrap-vue-next/dist/bootstrap-vue-next.css';
44
import './assets/css/main.css';
55

6-
import { createApp, computed, getCurrentInstance } from 'vue';
7-
import { createUnhead, useHead } from '@unhead/vue';
6+
import { createApp } from 'vue';
7+
import { createHead } from '@unhead/vue/legacy';
8+
import { VueHeadMixin } from '@unhead/vue';
89
import {
910
createBootstrap,
1011
Components as BVNComponents,
@@ -19,20 +20,9 @@ import i18n from './i18n';
1920

2021
const app = createApp(App);
2122

22-
// @unhead/vue — manages <head> reactively
23-
const head = createUnhead();
24-
app.use(head);
25-
26-
// Global mixin so Options API components can define a head() function
27-
app.mixin({
28-
setup() {
29-
const inst = getCurrentInstance();
30-
if (inst?.type?.head) {
31-
const headFn = inst.type.head;
32-
useHead(computed(() => headFn.call(inst.proxy)));
33-
}
34-
},
35-
});
23+
// @unhead/vue/legacy — proper Vue plugin with Options API head() support
24+
app.use(createHead());
25+
app.mixin(VueHeadMixin);
3626

3727
app.use(createBootstrap());
3828

0 commit comments

Comments
 (0)