Hide draft articles from the front page and mark drafts when viewed directly
Add an Article::published() scope and use it on the front page (which previously showed drafts), the /blog listing and the feeds. Draft articles are still reachable at their URL, but now show a draft notice, a "[Draft]" title prefix and a noindex robots meta tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eb35a0aa2d
commit
a31c218784
3 changed files with 84 additions and 7 deletions
|
|
@ -63,3 +63,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@layer components {
|
||||
.draft-notice {
|
||||
margin-block-end: 2ex;
|
||||
padding: 1ex 1em;
|
||||
border: 2px dashed var(--clr-border);
|
||||
border-radius: 8px;
|
||||
background: light-dark(
|
||||
oklch(95% 0.08 85deg),
|
||||
oklch(30% 0.08 85deg)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
@extends('master')
|
||||
|
||||
@section('title'){{ strip_tags($article->title) }} « @stop
|
||||
@section('title'){{ $article->published ? '' : '[Draft] ' }}{{ strip_tags($article->title) }} « @stop
|
||||
|
||||
@if (! $article->published)
|
||||
@push('head')
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
@endpush
|
||||
@endif
|
||||
|
||||
@section('content')
|
||||
@unless ($article->published)
|
||||
<aside class="draft-notice" role="note">
|
||||
<strong>Draft</strong> — this post hasn’t been published yet. It isn’t listed on the site or in feeds, so only people with this link can see it.
|
||||
</aside>
|
||||
@endunless
|
||||
@include('templates.article', ['article' => $article])
|
||||
@stop
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
@if (File::exists(public_path('gpg.key')))
|
||||
<link rel="pgpkey" href="{{ config('app.url')}}/gpg.key">
|
||||
@endif
|
||||
@stack('head')
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
|
|
|||
Loading…
Reference in a new issue