Skip to content

Commit ddded09

Browse files
committed
feat: nicer site preview
1 parent 290b513 commit ddded09

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

config/sections.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,25 @@
2222
$model = $model->clone(['content' => $changesVersion->content()->toArray()]);
2323
}
2424

25-
// if it's a site, show the home page URL
26-
$displayModel = $model instanceof Site ? $model->homePage() : $model;
27-
$meta = $model->metadata();
25+
// if it's a site, fall back to the home page for preview data
26+
$model = $model instanceof Site ? $model->homePage() : $model;
27+
if (!$model) {
28+
return null;
29+
}
2830

31+
$meta = $model->metadata();
2932
return [
30-
'page' => $displayModel ? $displayModel->slug() : '',
31-
'url' => $displayModel ? $displayModel->url() : '',
33+
'page' => $model->slug(),
34+
'url' => $model->url(),
35+
'pageTitle' => $model->title()->value(),
3236
'title' => $meta->metaTitle()->value(),
3337
'description' => $meta->metaDescription()->value(),
3438
'ogSiteName' => $meta->ogSiteName()->value(),
3539
'ogTitle' => $meta->ogTitle()->value(),
3640
'ogDescription' => $meta->ogDescription()->value(),
3741
'ogImage' => $meta->ogImage(),
3842
'cropOgImage' => $meta->cropOgImage()->toBool(),
43+
'panelUrl' => method_exists($model, 'panel') ? "{$model->panel()?->url()}?tab=seo" : null,
3944
];
4045
}
4146

index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)