However, not everything I do is strictly R related so I thought it would be cool to see if I can hook up Craft.do to serve as a secondary route for creating and integrating posts into my laboratory website.
The overall roadmap is as follows:
- Write 1-paged (with cover image and internal images) posts in Craft.do.
- Export as some type (currently supported types include Markdown & TextBundle as options.
- Copy the folder over to the root directory of the DLabWebsite.
- Write some custom R script to make a new distill blog post
- Trigger a build + git add + git commit + push action.
Let’s see how this can be done.
Exported File Types
TextBundle
A TextBundle is a different thing entirely. It is apparently ya single document bundle that contains two files:
- A info.json bundle
- A text.markdown text file.
There does not appear to be any tangible reason why a textBundle would be preferred over a single markdown file, so I’ll not consider it from here on.
Markdown
You can specify the flavor of markdown and the built-in types include Github. There is a nice interface here to select certain options on it and the ability to put it into a single markdown file.
One of the other things that I didn’t quite appreciate was that for images, like the one inserted above,
Craft will include an online reference to it on their craft servers. This does allow me to not have to upload everything to my flickr account, which is both nice (less steps) but troubling (what would happen if the craft servers go down or craft goes away (i no longer have all my stuff in one place). I suppose I could easily suck down all the images and relink them in the markdown if necessary. For now, I’ll call that a win.
Markdown 2 Distill
For this one, I think I’ll make a cheap and quick R solution to this. For that I’ll pick up in the next installment, and do it from the R side.
For this, I will enforce the following general rules.
- I’ll have to configure a featured image separate from this file (there is no opportunity for finding the location of the Cover Image at the top.).
- The title will be moved form H1 to markdown metadata title.
- The first paragraph will be taken and used as the description for the markdown metadata description.
- Save the raw markdown to a
_toImport
folder in the git repository for the site. The next time the site is built, it will convert the raw markdown into adistill::article
object and inserted in the appropriate place.
Once I get it all up and running, then I can wrap it all up in a shortcut.