/
githubmirror
/
hexo
Обзор
Документация
Войти
/
githubmirror
/
hexo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
4.2.0
lib/models/page.js
44 строки
1 KB
curbengh
refactor(permalink): full_url_for() has built in prettyUrls()
10 дек 2019, 15:05
10 дек 2019, 15:05
4c09f21
Код
Авторство
О чём код?
'use strict'; const { Schema } = require('warehouse'); const { join } = require('path'); const Moment = require('./types/moment'); const moment = require('moment'); const full_url_for = require('../plugins/helper/full_url_for'); module.exports = ctx => { const Page = new Schema({ title: {type: String, default: ''}, date: { type: Moment, default: moment, language: ctx.config.languages, timezone: ctx.config.timezone }, updated: { type: Moment, default: moment, language: ctx.config.languages, timezone: ctx.config.timezone }, comments: {type: Boolean, default: true}, layout: {type: String, default: 'page'}, _content: {type: String, default: ''}, source: {type: String, required: true}, path: {type: String, required: true}, raw: {type: String, default: ''}, content: {type: String}, excerpt: {type: String}, more: {type: String} }); Page.virtual('permalink').get(function() { return full_url_for.call(ctx, this.path); }); Page.virtual('full_source').get(function() { return join(ctx.source_dir, this.source || ''); }); return Page; };