Help with import and mobiledoc for Ghost 2.1.0


#1

I’m trying to modify the jekyll to ghost importer to import my old jekyll site to Ghost 2.0 successfully. I’ve gotten pretty close to being successful. Right now, this is what my JSON export looks like:

{
"data": {
    "posts": [
        {
            "author_id": 1,
            "created_at": 1305004800000,
            "created_by": 1,
            "feature_image": null,
            "featured": 0,
            "id": 0,
            "language": "en_US",
            "meta_description": null,
            "meta_title": null,
            "mobiledoc": {
                "atoms": [],
                "cards": [
                    [
                        "markdown",
                        {
                            "cardName": "markdown",
                            "markdown": "# Hello\nWorld"
                        }
                    ]
                ],
                "markups": [],
                "sections": [
                    [
                        10,
                        0
                    ]
                ],
                "version": "0.3.1"
            },
            "page": 0,
            "published_at": 1305004800000,
            "published_by": 1,
            "slug": "first-post",
            "status": "published",
            "title": "first post",
            "updated_at": 1305004800000,
            "updated_by": 1
        }
    ],
    "users": [
        {
            "accessibility": null,
            "bio": null,
            "cover_image": null,
            "created_at": 1537235410000,
            "created_by": 1,
            "email": "email@gmail.com",
            "id": 1,
            "language": "en_US",
            "last_login": null,
            "location": null,
            "meta_description": null,
            "meta_title": null,
            "name": "name",
            "profile_image": null,
            "slug": "name",
            "status": "active",
            "updated_at": 1537235410000,
            "updated_by": 1,
            "website": null
        }
    ]
},
"meta": {
    "exported_on": 1537235410000,
    "version": "2.1.0"
},
"posts_tags": [],
"tags": []
}

This successfully creates a new post with the correct title, but the body and content of the post is blank:

What is wrong with my mobiledoc structure? Is there more documentation on what exactly the JSON format needs to be to import posts? The documentation on the importer is pretty light.

Asked another way - how am I supposed to pass the content of the post in JSON? I’ve tried through html, markdown, and now mobiledoc keys in posts and they all end up creating a post with the title and an empty body.

  • What version of Ghost are you using? 2.1.0
  • What configuration? One click install on digital ocean -> Upgraded to 2.1.0
  • What browser? Chrome
  • What errors or information do you see in the console? None
  • What steps could someone else take to reproduce the issue you’re having?

#2

Hey @pfista,

I hear you - we don’t have anywhere near enough tooling or docs right now for imports and handling mobiledoc. I’m actively working on fixing this.

Quick fix for you right now (I think) is that you need to call JSON.stringify() on your mobiledoc object. It’s structured correctly, but it’s not in the right format for serialization to the DB.

If you’re not in a hurry, I’ll be releasing some tools to help with this stuff over the next few weeks and would love some people to test them early :slight_smile:


#3

Awesome, thanks @Hannah. I just tried this out and it worked :slight_smile:

Where can I stay up to date on the tools you’re working on? Also, I’m happy to help you test in the future.


#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.