@php
$isHomePage = request()->routeIs('tenant.home') || ($board->slug === 'pages' && $post->slug === 'home');
$siteSeoTitle = $tenantSiteSettings?->effectiveSeoTitle() ?: ($tenantSiteSettings?->effectiveSiteName() ?? 'qpost');
$siteSeoDescription = $tenantSiteSettings?->effectiveSeoDescription() ?: ($tenantSiteSettings?->site_description ?? 'qpost');
$siteSeoKeywords = $tenantSiteSettings?->effectiveSeoKeywords() ?: '';
$siteSeoCanonicalUrl = rtrim(tenant_canonical_url(), '/') . '/';
$siteSeoOgTitle = $tenantSiteSettings?->effectiveSeoOgTitle() ?: $siteSeoTitle;
$siteSeoOgDescription = $tenantSiteSettings?->effectiveSeoOgDescription() ?: $siteSeoDescription;
$siteSeoOgImage = $tenantSiteSettings?->effectiveSeoOgImageUrl() ?: '';
$normalizeMetaText = static function (?string $value): string {
$value = html_entity_decode(trim((string) $value), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$value = preg_replace('/<(script|style)\b[^>]*>.*?<\/\1>/is', ' ', $value) ?? $value;
$value = strip_tags($value);
$value = preg_replace('/\s+/u', ' ', $value) ?? $value;
return trim($value);
};
$contentDescription = $normalizeMetaText($post->content);
$pageTitle = $isHomePage
? tenant_home_title($tenantSiteSettings)
: tenant_page_title($post->title, $tenantSiteSettings);
$pageDescription = $isHomePage
? $siteSeoDescription
: ($normalizeMetaText($post->meta_description) !== ''
? $normalizeMetaText($post->meta_description)
: ($contentDescription !== '' ? Str::limit($contentDescription, 160, '') : $siteSeoDescription));
$pageKeywords = $isHomePage
? $siteSeoKeywords
: $normalizeMetaText($post->meta_keywords);
$pageCanonicalUrl = $isHomePage
? $siteSeoCanonicalUrl
: ($board->slug === 'pages' && $post->slug === 'home'
? rtrim(tenant_canonical_url(), '/') . '/'
: tenant_canonical_url(null, $board->slug . '/' . $post->slug));
$pageOgImage = $isHomePage
? $siteSeoOgImage
: (method_exists($post, 'thumbnailUrl') ? ($post->thumbnailUrl() ?: '') : '');
$pagePublishedAt = ($post->published_at ?? $post->created_at)?->toAtomString();
$pageModifiedAt = ($post->updated_at ?? $post->published_at ?? $post->created_at)?->toAtomString();
$pageArticleTags = $post->tags->pluck('name')->filter()->values();
@endphp
@extends('tenant.layouts.app')
@section('title', $pageTitle ?? ($isHomePage
? tenant_home_title($tenantSiteSettings)
: tenant_page_title($post->title, $tenantSiteSettings)))
@section('meta-description', $pageDescription)
@if ($pageKeywords !== '')
@section('meta-keywords', $pageKeywords)
@endif
@section('og-title', $isHomePage ? $siteSeoOgTitle : $post->title)
@section('og-description', $isHomePage ? $siteSeoOgDescription : $pageDescription)
@if ($pageOgImage !== '')
@section('og-image', $pageOgImage)
@endif
@section('canonical-url', $pageCanonicalUrl)
@section('header', $board->title)
@if ($isHomePage)
@section('og-type', 'website')
@elseif (! ($isPageSkin ?? false))
@section('og-type', 'article')
@endif
@if (! ($isPageSkin ?? false) && ! $isHomePage)
@push('head')
@foreach ($pageArticleTags as $pageArticleTag)
@endforeach
@php
$tenantPublisherName = $tenantSiteSettings?->site_name ?? 'qpost';
$tenantPublisherLogo = $tenantSiteSettings?->logo_path ? tenant_file_url($tenantSiteSettings->logo_path) : null;
$tenantArticleSchema = [
'@context' => 'https://schema.org',
'@type' => 'Article',
'headline' => $post->title,
'description' => $pageDescription,
'datePublished' => $pagePublishedAt,
'dateModified' => $pageModifiedAt,
'mainEntityOfPage' => $pageCanonicalUrl,
'articleSection' => $board->title,
'keywords' => $pageArticleTags->implode(', '),
'author' => [
'@type' => 'Person',
'name' => $post->user?->name ?? ($post->guest_name ?? '익명'),
],
'publisher' => [
'@type' => 'Organization',
'name' => $tenantPublisherName,
],
];
if ($tenantPublisherLogo) {
$tenantArticleSchema['publisher']['logo'] = [
'@type' => 'ImageObject',
'url' => $tenantPublisherLogo,
];
}
if ($pageOgImage !== '') {
$tenantArticleSchema['image'] = [$pageOgImage];
}
@endphp
@endpush
@endif
@if ($isPageSkin ?? false)
@php
$currentUser = auth('tenant')->user();
$showPagesToolbar = $currentUser?->isManager() ?? false;
@endphp
@if ($showPagesToolbar)
@section('body-top')