Skip to content

Commit fc1fc7a

Browse files
committed
refactor(permalink): full_url_for() has built in prettyUrls()
1 parent 92d06b5 commit fc1fc7a

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

lib/models/category.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { Schema } = require('warehouse');
4-
const { prettyUrls, slugize } = require('hexo-util');
4+
const { slugize } = require('hexo-util');
55
const full_url_for = require('../plugins/helper/full_url_for');
66

77
module.exports = ctx => {
@@ -39,10 +39,7 @@ module.exports = ctx => {
3939
});
4040

4141
Category.virtual('permalink').get(function() {
42-
const { config } = ctx;
43-
let url = full_url_for.call(ctx, this.path);
44-
url = prettyUrls(url, config.pretty_urls);
45-
return url;
42+
return full_url_for.call(ctx, this.path);
4643
});
4744

4845
Category.virtual('posts').get(function() {

lib/models/page.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const { join } = require('path');
55
const Moment = require('./types/moment');
66
const moment = require('moment');
77
const full_url_for = require('../plugins/helper/full_url_for');
8-
const { prettyUrls } = require('hexo-util');
98

109
module.exports = ctx => {
1110
const Page = new Schema({
@@ -34,10 +33,7 @@ module.exports = ctx => {
3433
});
3534

3635
Page.virtual('permalink').get(function() {
37-
const { config } = ctx;
38-
let url = full_url_for.call(ctx, this.path);
39-
url = prettyUrls(url, config.pretty_urls);
40-
return url;
36+
return full_url_for.call(ctx, this.path);
4137
});
4238

4339
Page.virtual('full_source').get(function() {

lib/models/post.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const { extname, join, sep } = require('path');
66
const Promise = require('bluebird');
77
const Moment = require('./types/moment');
88
const full_url_for = require('../plugins/helper/full_url_for');
9-
const { prettyUrls } = require('hexo-util');
109

1110
function pickID(data) {
1211
return data._id;
@@ -52,10 +51,7 @@ module.exports = ctx => {
5251
});
5352

5453
Post.virtual('permalink').get(function() {
55-
const { config } = ctx;
56-
let url = full_url_for.call(ctx, this.path);
57-
url = prettyUrls(url, config.pretty_urls);
58-
return url;
54+
return full_url_for.call(ctx, this.path);
5955
});
6056

6157
Post.virtual('full_source').get(function() {

lib/models/tag.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { Schema } = require('warehouse');
4-
const { prettyUrls, slugize } = require('hexo-util');
4+
const { slugize } = require('hexo-util');
55
const { hasOwnProperty: hasOwn } = Object.prototype;
66
const full_url_for = require('../plugins/helper/full_url_for');
77

@@ -30,10 +30,7 @@ module.exports = ctx => {
3030
});
3131

3232
Tag.virtual('permalink').get(function() {
33-
const { config } = ctx;
34-
let url = full_url_for.call(ctx, this.path);
35-
url = prettyUrls(url, config.pretty_urls);
36-
return url;
33+
return full_url_for.call(ctx, this.path);
3734
});
3835

3936
Tag.virtual('posts').get(function() {

0 commit comments

Comments
 (0)