hexojs / hexo-migrator-wordpress

WordPress migrator for Hexo.
http://hexo.io/docs/migration.html
MIT License
47 stars 30 forks source link

Excerpt is not migrated #33

Closed jashsayani closed 4 years ago

jashsayani commented 5 years ago

I use the "Read more…" tags a lot on my Wordpress blog. When I migrate the posts to hexo, the tags are not moved over from the xml file.

Tags in wordpress export: <!--more-->

Expected tag in hexo markdown (MISSING): <!-- more -->

I am using hexo-migrator-wordpress 1.0.0

curbengh commented 4 years ago

It's possible to fix https://github.com/hexojs/hexo-migrator-rss/issues/41

But still, if I can have a sample XML (https://github.com/hexojs/hexo-migrator-wordpress/issues/54), it can help me to verify that the excerpt is imported correctly.

adnan360 commented 4 years ago

@curbengh An implementation of that would really help me. Here is a test export (zipped): test.WordPress.2020-06-26.xml.zip

== In XML exports:

It seems classic editor puts:

<!--more-->

And Gutenberg editor puts (including block tags):

<!-- wp:more -->
<!--more-->
<!-- /wp:more -->

== After migration:

My migration plugin was at 1.0.0.

hello-world.md (Hello World post written in Gutenberg) has:

---
title: Hello world!
url: 1.html
id: 1
categories:
  - Uncategorized
date: 2020-06-26 10:34:42
tags:
---

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

This is some text after the more tag.

There is no more tag anywhere.

classic-post.md (Classic Post written in Classic editor) has:

---
title: Classic Post
url: 9.html
id: 9
categories:
  - Uncategorized
date: 2020-06-26 11:01:34
tags:
---

This is a test excerpt before the more tag edited in Classic Editor. This is some content after the more tag. This will be some more content for test.

There is no more tag and the content after more tag has been merged with the line before it. EDIT: Added screenshots, minor edits

curbengh commented 4 years ago

@adnan360

Thanks for the attachment, it's good to have Gutenberg version.

May I know which tag are you referring?

---
title: Classic Post
+tags:
---

or

<!--more-->
adnan360 commented 4 years ago

May I know which tag are you referring?

I was referring to <!--more-->

adnan360 commented 4 years ago

@SukkaW @curbengh I think there is an issue. Separate Hexo posts are created for WordPress Media uploads. I have also used external <img> tags, but they don't create posts. I'm not sure if it's related to this PR though.

I've posted about this, but maybe wasn't fast enough. Posted just some seconds after merging. Sorry I didn't test with images at first. I thought it was a PR for excerpt, so it never occurred to me that this could happen.

A further look into the xml brought me to conclusion that we are somehow taking all <item>...</item> elements into consideration. Media uploads are also considered internally as posts by WordPress. So maybe that's why they are also in the xml as <item>s.

                    <item>
        <title>greens-4926370_640</title>
        <link>http://localhost/wp-hexotest/2020/07/04/post-with-image-classic-editor/greens-4926370_640/</link>
...
        <dc:creator><![CDATA[admin]]></dc:creator>
        <guid isPermaLink="false">http://localhost/wp-hexotest/wp-content/uploads/2020/07/greens-4926370_640.jpg</guid>
...
        <wp:post_type><![CDATA[attachment]]></wp:post_type>
...
</item

We'll have to ignore <item>s with <wp:post_type><![CDATA[attachment]]></wp:post_type> to create separate posts for them.

EDIT: minor edits, mentions

curbengh commented 4 years ago

We'll have to ignore <item> with <wp:post_type><![CDATA[attachment]]></wp:post_type> to create separate posts for them.

Thanks for the insight. The zip file that you attached can be useful in tackling https://github.com/hexojs/hexo-migrator-wordpress/issues/37.