Added code highlighting
This commit is contained in:
@@ -2,6 +2,10 @@ import {
|
||||
DataTypes,
|
||||
sequelize,
|
||||
} from '../sequelize';
|
||||
import {
|
||||
convertToMarkdown,
|
||||
truncateMarkdown,
|
||||
} from '../utils/markdown';
|
||||
import Atlas from './Atlas';
|
||||
import Team from './Team';
|
||||
import User from './User';
|
||||
@@ -10,6 +14,15 @@ const Document = sequelize.define('document', {
|
||||
id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
|
||||
title: DataTypes.STRING,
|
||||
text: DataTypes.TEXT,
|
||||
html: DataTypes.TEXT,
|
||||
preview: DataTypes.TEXT,
|
||||
}, {
|
||||
hooks: {
|
||||
beforeCreate: (doc) => {
|
||||
doc.html = convertToMarkdown(doc.text);
|
||||
doc.preview = truncateMarkdown(doc.text, 160);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
Document.belongsTo(Atlas, { as: 'atlas' });
|
||||
|
||||
Reference in New Issue
Block a user