登录时的替代页面标题和元数据

我想知道如何在登录页面上显示替代“标题”和其他元数据。

假设我有一个目标 URL,例如https://example.com/thing/12345 ...如果未登录,用户将被重定向到登录页面,这就是我想要的,但在登录页面上我想从目标页面注入标题,也许还有其他元数据。

因此,如果在 Facebook 中共享上述链接,它将显示目标 URL 的标题/元数据,而不是登录 URL。


哔哔one
浏览 113回答 1
1回答

慕无忌1623718

根据 Laravel 文档:在您的主模板中使用@yield('title')动态更改标题<html>&nbsp; &nbsp; <head>&nbsp; &nbsp; &nbsp; &nbsp; <title>App Name - @yield('title')</title>&nbsp; //&nbsp; add this code&nbsp; &nbsp; </head>&nbsp; &nbsp; <body>&nbsp; &nbsp; &nbsp; &nbsp; @section('sidebar')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; This is the master sidebar.&nbsp; &nbsp; &nbsp; &nbsp; @show&nbsp; &nbsp; &nbsp; &nbsp; <div class="container">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @yield('content')&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </body></html>从您的刀片模板中使用@section('title')将标题传递给主布局@extends('layouts.master')@section('title', 'Page Title') // pass dynamic title from here@section('sidebar')&nbsp; &nbsp; @parent&nbsp; &nbsp; <p>This is appended to the master sidebar.</p>@stop@section('content')&nbsp; &nbsp; <p>This is my body content.</p>@stopLaravel -> 模板 -> 刀片模板
打开App,查看更多内容
随时随地看视频慕课网APP