medium-to-hugo icon indicating copy to clipboard operation
medium-to-hugo copied to clipboard

The tool only converts drafts, not posts.

Open brismuth opened this issue 5 years ago • 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;
      }

brismuth avatar Oct 18 '20 21:10 brismuth

Thanks for that , fixed my issue commenting the whole line

bechampion avatar Aug 22 '21 13:08 bechampion

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
}

nardiyansah avatar Aug 30 '21 02:08 nardiyansah

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

nardiyansah avatar Aug 30 '21 02:08 nardiyansah

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 avatar Oct 11 '21 03:10 sylwit

@sylwit's solution worked for me as well!

reteps avatar Dec 30 '22 03:12 reteps

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.

rtenacity avatar Jan 04 '23 16:01 rtenacity