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

A mechanism for associating a post to a Dev.to Organization #21

Open pabloromeo opened 2 years ago

pabloromeo commented 2 years ago

It appears that by default posts get created as Personal. I was wondering if there was a setting to have it default to an Organization I'm part of. You can manually edit it in Dev.to later, and all seems well with the sync later on anyways, so it isn't a blocker at the moment.

Also, I tried to get it working when the repo was private, and local assets weren't accesible so it would fail. The only options are to either have the repo public or manually upload the content somewhere public correct?

sinedied commented 2 years ago

You can try adding organization_id: <number> in your article front matter. I saw that it was recently added to the dev.to API, but it wasn't back when I pushed last update. I'll probably fully support it when I can find some time to work on it, as retrieving it from existing article needs a bit more work, and involves rethinking the reconciliation process.

Also, I tried to get it working when the repo was private, and local assets weren't accessible so it would fail. The only options are to either have the repo public or manually upload the content somewhere public correct?

Yes, you're correct. It would be nice to allow uploading assets directly to the dev.to platform, but this feature isn't currently supported by their API.

pabloromeo commented 2 years ago

Nice! I'll give that organization_id a shot. Thanks! Very useful tool by the way 👍

pabloromeo commented 2 years ago

Forgot to mention, I did try including the organization_id in front_matter, it was just ignored. Now, that might actually be an interesting approach to linking articles to organizations. Meaning, if devto-cli looked for organization_id within front-matter, and if found, included the extra organization_id paramter during creation or updates, then I believe it would link those (after validating that the user is part of the org). For reconciliation there may not be a need to worry about it though, unless you want to link an article to another organization, right? Since I think you can still issue an update on an article linked to one organization, without including any organization_id and it wouldn't alter the association nor make the article a "personal" one.

sinedied commented 2 years ago

Thanks for the update! I'll have a look at the cause when I get the chance, I suspect that organization_id property is filtered out before sending the message to the API, so it might just be a matter of updating the models so that property is propery passed on to the API.

pabloromeo commented 2 years ago

I tried manually editing an article in dev.to by modifying the front-matter content and adding organization_id as a property, but it ignored it too and didn't link the article. I get the feeling dev.to only supports receiving an organization_id as an extra parameter to the call, and not inlined in front-mater, unfortunately :(

pabloromeo commented 1 year ago

Hi :), I was wondering if you'd been able to look into the new api endpoints that seem to support the organization_id as arguments, to be able to publish articules linked to organizations.

sinedied commented 1 year ago

Hey, sorry for the (long) delay. I haven't got the time to look into it yet, but if you want to give it a try I'll gladly accept a PR 🙂