我想实现 facebook 分享按钮功能,它会在用户点击分享按钮期间捕获元标记信息。
我有一个 head.blade.php,其中包含一些要捕获的元标记。例子
<meta property="og:url" content="@yield('facebook_share_url')">
<meta property="og:image" content="@yield('facebook_share_image')">
<meta property="og:description" content="@yield('facebook_share_description')">
我有一个default.blade.php。
<!doctype html>
<html>
<head>
@include('includes.head')
</head>
<body>
<div class="container">
<header class="row">
@include('includes.header')
</header>
<div id="main" class="row">
@yield('content')
</div>
</div>
@include('includes.footer')
</body>
</html>
因此,当我浏览到某个 url 说 www.example.com/details 时,default.blade.php 将产生来自这个 details.blade 的内容。此时我想更改 facebook 元标记属性,所以我在详细信息页面中做了如下操作。
@section('facebook_share_image', 'This is a description')
@section('facebook_share_description', 'This is an individual page title')
代码工作正常,但我想从我的视图数据中呈现它。就像是@section('facebook_share_description', {{ $data->description }})
但是当我检查我的元标记时,它什么也没给我。有可能这样做吗?