Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The tool only converts drafts, not posts. #6

Open
brismuth opened this issue Oct 18, 2020 · 6 comments
Open

The tool only converts drafts, not posts. #6

brismuth opened this issue Oct 18, 2020 · 6 comments

Comments

@brismuth
Copy link

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;
      }
@bechampion
Copy link

Thanks for that , fixed my issue commenting the whole line

@nardiyansah
Copy link

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
Copy link

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

@sylwit
Copy link

sylwit commented Oct 11, 2021

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

@reteps
Copy link

reteps commented Dec 30, 2022

@sylwit's solution worked for me as well!

@rtenacity
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants