Add (auto indexing): when set to publish
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
if (! function_exists('str_first_sentence')) {
|
||||
function str_first_sentence($str) {
|
||||
function str_first_sentence($str)
|
||||
{
|
||||
// Split the string at ., !, or ?
|
||||
$sentences = preg_split('/(\.|!|\?)(\s|$)/', $str, 2);
|
||||
|
||||
|
||||
@@ -125,6 +125,14 @@ public function postUpsert(Request $request)
|
||||
]);
|
||||
}
|
||||
|
||||
if ($existingPost->status == 'publish') {
|
||||
|
||||
$post_url = route('home.country.post', ['country' => $existingPost->post_category?->category?->country_locale_slug, 'post_slug' => $existingPost->slug]);
|
||||
|
||||
LaravelGoogleIndexing::create()->update($post_url);
|
||||
IndexNow::submit($post_url);
|
||||
}
|
||||
|
||||
// Return a response indicating a successful update
|
||||
return response()->json(['message' => 'Post updated successfully', 'action' => 'redirect_back']);
|
||||
} else {
|
||||
@@ -143,6 +151,13 @@ public function postUpsert(Request $request)
|
||||
]);
|
||||
}
|
||||
|
||||
if ($newPost->status == 'publish') {
|
||||
$post_url = route('home.country.post', ['country' => $newPost->post_category?->category?->country_locale_slug, 'post_slug' => $newPost->slug]);
|
||||
|
||||
LaravelGoogleIndexing::create()->update($post_url);
|
||||
IndexNow::submit($post_url);
|
||||
}
|
||||
|
||||
// Return a response indicating a successful creation
|
||||
return response()->json(['message' => 'Post created successfully', 'action' => 'redirect_back']);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
'list' => [
|
||||
'style' => [
|
||||
'type' => 'string',
|
||||
'allowedValues' => ['ordered', 'unordered']
|
||||
'allowedValues' => ['ordered', 'unordered'],
|
||||
],
|
||||
'items' => [
|
||||
'type' => 'array',
|
||||
|
||||
@@ -30,7 +30,8 @@ class="text-decoration-none">{{ $post->title }}</a>
|
||||
</div>
|
||||
@else
|
||||
<div class="mb-3">
|
||||
<small class="text-secondary">{{ str_first_sentence($post->excerpt) }}</small>
|
||||
<small
|
||||
class="text-secondary">{{ str_first_sentence($post->excerpt) }}</small>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user