Skip to content

Commit

Permalink
feat(post): remove front-matter property link (#5253)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Jul 27, 2023
1 parent 0257bb3 commit 99e94cc
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 33 deletions.
1 change: 0 additions & 1 deletion lib/models/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export = ctx => {
source: {type: String, required: true},
slug: {type: String, required: true},
photos: [String],
link: {type: String, default: ''},
raw: {type: String, default: ''},
published: {type: Boolean, default: true},
content: {type: String},
Expand Down
4 changes: 0 additions & 4 deletions lib/plugins/processor/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ function processPost(ctx, file) {
data.photos = [data.photos];
}

if (data.link && !data.title) {
data.title = data.link.replace(/^https?:\/\/|\/$/g, '');
}

if (data.permalink) {
data.__permalink = data.permalink;
data.permalink = undefined;
Expand Down
1 change: 0 additions & 1 deletion test/scripts/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('Post', () => {
data.comments.should.be.true;
data.layout.should.eql('post');
data._content.should.eql('');
data.link.should.eql('');
data.raw.should.eql('');
data.published.should.be.true;
should.not.exist(data.updated);
Expand Down
28 changes: 1 addition & 27 deletions test/scripts/processors/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,33 +778,7 @@ describe('post', () => {
]);
});

it('post - link without title', async () => {
const body = [
'link: https://hexo.io/',
'---'
].join('\n');

const file = newFile({
path: 'foo.html',
published: true,
type: 'create',
renderable: true
});

await writeFile(file.source, body);
await process(file);
const post = Post.findOne({ source: file.path });

post.link.should.eql('https://hexo.io/');
post.title.should.eql('hexo.io');

return Promise.all([
post.remove(),
unlink(file.source)
]);
});

it('post - link without title and link', async () => {
it('post - without title', async () => {
const body = '';

const file = newFile({
Expand Down

0 comments on commit 99e94cc

Please sign in to comment.