sinedied / devto-cli

Dev.to authoring CLI to create and publish markdown files as articles, using assets hosted on GitHub.
MIT License
32 stars 3 forks source link

Allow local structure for posts #22

Open rpsu opened 2 years ago

rpsu commented 2 years ago

I published a couple of old posts to Dev.to and the process was very smooth. I have markdown file structure with year to allow some structure within the posts lists locally.

posts/
   2015/*.md
   2017/*.md

However when I pull the posts back from dev.to dev i -p -s --verbose the tool does not find the old posts in the subfolders but copies them directly under posts/

Am I missing some configuration option, some flag maybe?

To me this looks like the filename is converted from the front matter title on pull. While it works just fine when publishing pulling does not consider all local files (my existing post files in subfolders) while pushing out works.

Concrete example:

  1. write post to file posts/2022/example.md with title: Example, commit to git
  2. publish it with dev p posts/2022/example.md
  3. pull all posts with dev i -p -s
  4. the newly created post (and all other posts) appears now also in the file posts/example.md
sinedied commented 2 years ago

The dev init --pull option was only meant to facilitate the initial import when you're trying to setup you repo, it should not be used for sync'ing back changes coming from the website. There's currently no way to know what was the original folder structure anyways.

That being said, it's on my plans to add a specific command to pull back changes from existing articles from devto, if made changes on the website and want to import them back in your repo. It's a bit tricky as you need to reprocess URLs and reconcile with local changes (if any), so it might take some time.