PHP code example of ycs77 / inertia-laravel-ssr-head
1. Go to this page and download the library: Download ycs77/inertia-laravel-ssr-head library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return Inertia::render('Home')
->title('My homepage')
->description('Hello, This is my homepage~');
use Inertia\Inertia;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Inertia::titleTemplate(fn ($title) => $title ? "$title - My App" : 'My App');
// or pass string and %s will be replaced with the page title
Inertia::titleTemplate('%s - My App');
}
}
return Inertia::render('Home')
->title('My homepage', '%s :: My App');
return Inertia::render('Home')
->title('My homepage')
->description('Hello, This is my homepage~')
->image('https://example.com/image')
->ogMeta();
// Same...
return Inertia::render('Home')
->title('My homepage')
->description('Hello, This is my homepage~')
->image('https://example.com/image')
->ogTitle('My homepage')
->ogDescription('Hello, This is my homepage~')
->ogImage('https://example.com/image');
return Inertia::render('Home')
->title('My homepage')
->ogTitle('Custom og title')
->ogDescription('Custom og description...');
return Inertia::render('Home')
->title('My homepage')
->description('Hello, This is my homepage~')
->image('https://example.com/image')
->twitterSummaryCard();
return Inertia::render('Home')
->title('My homepage')
->description('Hello, This is my homepage~')
->image('https://example.com/image')
->twitterLargeCard()
->twitterCreator('@creator_twitter_name');