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
1 changed files with 84 additions and 7 deletions
|
|
@ -101,6 +101,14 @@ class Article extends Model
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include published (non-draft) articles.
|
||||
*/
|
||||
public function scopePublished(Builder $query): Builder
|
||||
{
|
||||
return $query->where('published', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include articles from a particular year/month.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue