feat(content-type): add content_type field, markdown auto-conversion, and API doc updates

- Add content_type column to ul_post via migration
- Install league/commonmark for markdown->HTML conversion
- Add Post model accessors/setters for content_type and content
- Update API Articles controller save/update with content_type support
- Update API docs with content_type parameter and markdown example

Closes content-type-support plan
This commit is contained in:
augushong
2026-04-29 20:46:44 +08:00
parent 0e8944bc7f
commit 6f332467df
5 changed files with 104 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use think\migration\Migrator;
use think\migration\db\Column;
class AddContentTypeToPost extends Migrator
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->table('post')->addColumn(
Column::make('content_type', 'string', ['limit' => 20, 'default' => 'html', 'comment' => '内容类型: html/markdown'])
)->update();
}
}