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
|
|
@ -17,7 +17,7 @@ class ArticlesController extends Controller
|
|||
*/
|
||||
public function index(?int $year = null, ?int $month = null): View
|
||||
{
|
||||
$articles = Article::where('published', '1')
|
||||
$articles = Article::published()
|
||||
->date($year, $month)
|
||||
->orderBy('updated_at', 'desc')
|
||||
->simplePaginate(5);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class FeedsController extends Controller
|
|||
*/
|
||||
public function blogJson(): JsonResponse
|
||||
{
|
||||
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
||||
$articles = Article::published()->latest('updated_at')->take(20)->get();
|
||||
$data = [
|
||||
'version' => 'https://jsonfeed.org/version/1.1',
|
||||
'title' => 'The JSON Feed for '.config('user.display_name').'’s blog',
|
||||
|
|
@ -89,7 +89,7 @@ class FeedsController extends Controller
|
|||
*/
|
||||
public function blogJf2(): JsonResponse
|
||||
{
|
||||
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
||||
$articles = Article::published()->latest('updated_at')->take(20)->get();
|
||||
$items = [];
|
||||
foreach ($articles as $article) {
|
||||
$items[] = [
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class FrontPageController extends Controller
|
|||
->withCount(['webmentions AS reposts' => function ($query) {
|
||||
$query->where('type', 'repost-of');
|
||||
}])->get();
|
||||
$articles = Article::latest()->get();
|
||||
$articles = Article::published()->latest()->get();
|
||||
$bookmarks = Bookmark::latest()->with('tags')->get();
|
||||
$likes = Like::latest()->get();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue