From 4036c1e298103507788a39943088a6e563c61bc2 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Wed, 12 Jul 2023 12:49:22 +0800 Subject: [PATCH] feat(post): remove front-matter property `link` --- lib/models/post.ts | 1 - lib/plugins/processor/post.ts | 4 ---- test/scripts/models/post.js | 1 - test/scripts/processors/post.js | 28 +--------------------------- 4 files changed, 1 insertion(+), 33 deletions(-) diff --git a/lib/models/post.ts b/lib/models/post.ts index 60695323ec..56e9f8cf6f 100644 --- a/lib/models/post.ts +++ b/lib/models/post.ts @@ -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}, diff --git a/lib/plugins/processor/post.ts b/lib/plugins/processor/post.ts index dca6306e62..e433858084 100644 --- a/lib/plugins/processor/post.ts +++ b/lib/plugins/processor/post.ts @@ -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; diff --git a/test/scripts/models/post.js b/test/scripts/models/post.js index e2bf189da0..ded1dc66be 100644 --- a/test/scripts/models/post.js +++ b/test/scripts/models/post.js @@ -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); diff --git a/test/scripts/processors/post.js b/test/scripts/processors/post.js index 9cb00b3ac7..1beb68207f 100644 --- a/test/scripts/processors/post.js +++ b/test/scripts/processors/post.js @@ -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({