Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = ctx => {
const PostAsset = new Schema({
_id: {type: String, required: true},
slug: {type: String, required: true},
modified: {type: Boolean, default: true},
post: {type: Schema.Types.CUID, ref: 'Post'},
renderable: {type: Boolean, default: true}
});
PostAsset.virtual('path').get(function() {
const Post = ctx.model('Post');
const post = Post.findById(this.post);
if (!post) return;
// PostAsset.path is file path relative to `public_dir`
// no need to urlescape, #1562
// strip /\.html?$/ extensions on permalink, #2134
return pathFn.join(_.replace(post.path, /\.html?$/, ''), this.slug);
});
PostAsset.virtual('source').get(function() {
return pathFn.join(ctx.base_dir, this._id);
module.exports = ctx => {
const PostCategory = new Schema({
post_id: {type: Schema.Types.CUID, ref: 'Post'},
category_id: {type: Schema.Types.CUID, ref: 'Category'}
});
return PostCategory;
};
module.exports = ctx => {
const Category = new Schema({
name: {type: String, required: true},
parent: {type: Schema.Types.CUID, ref: 'Category'}
});
Category.virtual('slug').get(function() {
let name = this.name;
if (!name) return;
let str = '';
if (this.parent) {
const parent = ctx.model('Category').findById(this.parent);
str += `${parent.slug}/`;
}
const map = ctx.config.category_map || {};
module.exports = ctx => {
const PostTag = new Schema({
post_id: {type: Schema.Types.CUID, ref: 'Post'},
tag_id: {type: Schema.Types.CUID, ref: 'Tag'}
});
return PostTag;
};
module.exports = ctx => {
const PostTag = new Schema({
post_id: {type: Schema.Types.CUID, ref: 'Post'},
tag_id: {type: Schema.Types.CUID, ref: 'Tag'}
});
return PostTag;
};
module.exports = ctx => {
const PostCategory = new Schema({
post_id: {type: Schema.Types.CUID, ref: 'Post'},
category_id: {type: Schema.Types.CUID, ref: 'Category'}
});
return PostCategory;
};