'use strict'; /** * 文档内容页(doc_articles) * * 直接挂在栏目下(两级结构),一个栏目下的一批内容页就是文档站左侧的导航列表。 * - `content`:Markdown 原文(保存后由 `service/docSite` 渲染成静态 HTML) * - `slug`:URL 片段(`/doc/<栏目 code>/.html`),创建后不能改 * - `status`:1 发布 0 草稿(草稿不生成页面,也不进 sitemap) */ module.exports = (app) => { const { BIGINT, STRING, TINYINT, INTEGER, TEXT } = app.Sequelize; const DocArticle = app.model.define('doc_article', { id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' }, sectionId: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属栏目 doc_sections.id' }, title: { type: STRING(128), allowNull: false, comment: '标题' }, slug: { type: STRING(64), allowNull: false, comment: 'URL 片段(/doc/<栏目>/.html)' }, summary: { type: STRING(255), allowNull: true, comment: '摘要(列表 / meta description)' }, content: { type: TEXT('medium'), allowNull: true, comment: '正文(Markdown)' }, sort: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 0, comment: '栏目内排序(小的在前)' }, status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1 发布 0 草稿' }, }, { tableName: 'doc_articles', paranoid: true, comment: '文档内容页表', }); return DocArticle; };