2
0
Эх сурвалжийг харах

summary提取note开头第一段

visuddhinanda 2 өдөр өмнө
parent
commit
e8471ce08b

+ 6 - 2
api-v12/app/Http/Resources/TermResource.php

@@ -13,6 +13,7 @@ use App\Http\Api\ShareApi;
 use App\Http\Api\AuthApi;
 use App\Http\Api\AuthApi;
 use App\Models\UserOperationDaily;
 use App\Models\UserOperationDaily;
 use App\Models\DhammaTerm;
 use App\Models\DhammaTerm;
+use App\Helpers\MarkdownHelper;
 
 
 class TermResource extends JsonResource
 class TermResource extends JsonResource
 {
 {
@@ -66,12 +67,15 @@ class TermResource extends JsonResource
             $mdRender = new MdRender(
             $mdRender = new MdRender(
                 [
                 [
                     'mode' => $request->input('mode', 'read'),
                     'mode' => $request->input('mode', 'read'),
-                    'format' => 'react',
+                    'format' => $request->input('format', 'react'),
                     'studioId' => $this->owner,
                     'studioId' => $this->owner,
                 ]
                 ]
             );
             );
             $data["html"]  = $mdRender->convert($this->note, $channels, null);
             $data["html"]  = $mdRender->convert($this->note, $channels, null);
-            $summaryContent = $this->note;
+            $paragraphs = MarkdownHelper::splitByParagraphs($this->note);
+            if (is_array($paragraphs) && count($paragraphs) > 0) {
+                $summaryContent = $paragraphs[0];
+            }
         } else if ($request->has('community_summary')) {
         } else if ($request->has('community_summary')) {
             $lang = strtolower($this->language);
             $lang = strtolower($this->language);
             if ($lang === 'zh') {
             if ($lang === 'zh') {