bgadrian/medium-to-hugo

The tool only converts drafts, not posts.

Opened this issue · 6 comments

I'm trying to use the tool on a medium export I just made, and it's only converting drafts, and not comments.

Here's the command I'm using:
~/path/to/mediumtohugo/macos/mediumtohugo /path/to/medium-export/posts/ /path/to/dest posts

It outputs messages like this for everything that isn't a draft:

Ignoring (comment) 2016-06-16_Steam-In-Home-Streaming-on-a-Chromebook-7d3e7c382532.html

Looks like line 137 in main.go might be to blame?

	//Medium treats comments/replies as posts
	p.IsComment = doc.Find(".aspectRatioPlaceholder").Length() == 0

All of my posts (not just comments) contain these lines:

      .aspectRatioPlaceholder {
        max-width: auto !important;
        max-height: auto !important;
      }
      .aspectRatioPlaceholder-fill {
        padding-bottom: 0 !important;
      }

Thanks for that , fixed my issue commenting the whole line

On my exported medium posts, my draft has the prefix "draft" in the filename, so I add a new condition when checking file will ignore or not.

if !strings.HasSuffix(f.Name(), ".html") || f.IsDir() || strings.HasPrefix(f.Name(), "draft") {
	fmt.Printf("Ignoring (ext) %s\n", f.Name())
	continue
}

I also change the selector for checking it is a comment or not.

//Medium treats comments/replies as posts
p.IsComment = doc.Find("p[class='graf graf--p graf--leading graf--trailing']").Length() > 0

I see this class in every my comment .html

Based on @nardiyansah solution, I have some comments without the graf-traling class so what's worked for me is

p.IsComment = doc.Find(".graf.graf--p.graf--leading").Length() > 0

@sylwit's solution worked for me as well!

I fixed this issue by forking the repository and commenting out line 137. If you're interested in just building my solution, download https://github.com/rtenacity/medium-to-hugo and build it from there.