8000 Inertia implementation not working · Issue #333 · artesaos/seotools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Inertia implementation not working #333
Open
@maarten-mald-digital

Description

@maarten-mald-digital

In the link Inertia SEO is implemented but i cant get it working or do not understand how.

Static home.vue

<template>
    <div class="blocks">
        <Head>
            <title>Home</title>
            <meta name="description" content="The homepage" />
        </Head>

        <h1>Home</h1>
        <hr />

        <Link :href="route('templates.home')">Home</Link>
        <Link :href="route('templates.product')">Product</Link>
    </div>
</template>

<script setup>
import { Link } from '@inertiajs/vue3';
import { Head } from '@inertiajs/vue3';
</script>

The title and description are printed. Switching to /product changes according to my product.vue
Image

When trying to make dynamic

config/seotools.php

'inertia' => true,

routes/templates.php

<?php

use Artesaos\SEOTools\Facades\JsonLd;
use Artesaos\SEOTools\Facades\OpenGraph;
use Artesaos\SEOTools\Facades\SEOMeta;
use Artesaos\SEOTools\Facades\SEOTools;
use Artesaos\SEOTools\Facades\TwitterCard;

use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

Route::get('/', function () {
    SEOMeta::setTitle('home dynamic');
    SEOMeta::setDescription('home dynamic description');

    $seo = SEOTools::generate();

    return Inertia::render('templates/Home', ['seo' => $seo]);
})->name('home');

Route::get('/product', function () {
    SEOMeta::setTitle('product dynamic');
    SEOMeta::setDescription('product dynamic description');

    $seo = SEOTools::generate();

    return Inertia::render('templates/Product', ['seo' => $seo]);
})->name('product');

home.vue

<template>
    <div class="blocks">
        <Head>
            {{ seo }}
        </Head>

        <h1>Home</h1>
        <hr />

        <Link :href="route('templates.home')">Home</Link>
        <Link :href="route('templates.product')">Product</Link>
    </div>
</template>

<script setup>
import { Link } from '@inertiajs/vue3';
import { Head } from '@inertiajs/vue3';

const props = defineProps({
    seo: {
        type: Object,
    },
});
</script>

Looking at home, the title is applied, the description is not printed
Image

When i remove title (only appending description)

Description is applied
Image

When switching between /home and /product it goes dynamic, but only 1 seo item is printed.

Its weird because when i generate the title + description and log using

{{ seo }}
both are there

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0