diff --git a/core/server/data/importer/importers/data/posts.js b/core/server/data/importer/importers/data/posts.js index 3d11af836a..7aed40885b 100644 --- a/core/server/data/importer/importers/data/posts.js +++ b/core/server/data/importer/importers/data/posts.js @@ -216,6 +216,12 @@ class PostsImporter extends BaseImporter { mobiledoc = mobiledocLib.blankDocument; } + // ghostVersion was introduced in 4.0. Any earlier content won't have it set + // so we should set it to "3.0" to match rendering output + if (!mobiledoc.ghostVersion) { + mobiledoc.ghostVersion = '3.0'; + } + mobiledoc.cards.forEach((card) => { // Ghost 1.0 markdown card = 'card-markdown', Ghost 2.0 markdown card = 'markdown' if (card[0] === 'card-markdown') { diff --git a/test/regression/importer/importer_spec.js b/test/regression/importer/importer_spec.js index 1d1f7135f7..db00681251 100644 --- a/test/regression/importer/importer_spec.js +++ b/test/regression/importer/importer_spec.js @@ -1145,7 +1145,6 @@ describe('Integration: Importer', function () { slug: 'post1', mobiledoc: JSON.stringify({ version: '0.3.1', - ghostVersion: '3.0', // 3.0 is when ghostVersion was introduced markups: [], atoms: [], cards: [ @@ -1175,7 +1174,7 @@ describe('Integration: Importer', function () { posts.length.should.eql(1); - posts[0].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["image",{"src":"source","cardWidth":"wide"}],["markdown",{"markdown":"# Post Content"}]],"sections":[[10,0],[10,1]]}'); + posts[0].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["image",{"src":"source","cardWidth":"wide"}],["markdown",{"markdown":"# Post Content"}]],"sections":[[10,0],[10,1]],"ghostVersion":"3.0"}'); posts[0].html.should.eql('

Post Content

\n'); }); }); @@ -1187,7 +1186,6 @@ describe('Integration: Importer', function () { slug: 'post1', mobiledoc: JSON.stringify({ version: '0.3.1', - ghostVersion: '3.0', // 3.0 is when ghostVersion was introduced markups: [], atoms: [], cards: [ @@ -1209,7 +1207,6 @@ describe('Integration: Importer', function () { slug: 'post2', mobiledoc: JSON.stringify({ version: '0.3.1', - ghostVersion: '3.0', markups: [], atoms: [], cards: [ @@ -1238,10 +1235,10 @@ describe('Integration: Importer', function () { posts.length.should.eql(2); - posts[0].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["markdown",{"markdown":"## Post Content"}],["image",{"src":"source2","cardWidth":"not-wide"}]],"sections":[[10,0],[10,1]]}'); + posts[0].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["markdown",{"markdown":"## Post Content"}],["image",{"src":"source2","cardWidth":"not-wide"}]],"sections":[[10,0],[10,1]],"ghostVersion":"3.0"}'); posts[0].html.should.eql('

Post Content

\n
'); - posts[1].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["image",{"src":"source","cardWidth":"wide"}],["markdown",{"markdown":"# Post Content"}]],"sections":[[10,0],[10,1]]}'); + posts[1].mobiledoc.should.eql('{"version":"0.3.1","markups":[],"atoms":[],"cards":[["image",{"src":"source","cardWidth":"wide"}],["markdown",{"markdown":"# Post Content"}]],"sections":[[10,0],[10,1]],"ghostVersion":"3.0"}'); posts[1].html.should.eql('

Post Content

\n'); }); });