Transform HTML Content to Apple News / Google AMP / Facebook Instant Articles with Distro

distro

Automatically transform article HTML for third-party platforms such as Facebook Instant Articles, Apple News, Google AMP

“Just” make a curl request …

curl --data "
<h1>Distro.Mic example</h1>
<p>Text and media embed</p>
<iframe src=\"https://www.youtube.com/embed/M7lc1UVf-VE\"></iframe>
" https://distro.mic.com/1.0/format?output=apple-news

… and the content is “translated” to the specified format:

{
	"article": [{
		"text": "Distro.Mic example",
		"additions": [],
		"inlineTextStyles": [],
		"role": "heading1",
		"layout": "bodyLayout"
	}, {
		"text": "Text and media embed\n",
		"additions": [],
		"inlineTextStyles": [],
		"role": "body",
		"layout": "bodyLayout"
	}, {
		"role": "container",
		"components": [{
			"role": "embedwebvideo",
			"URL": "https://www.youtube.com/embed/M7lc1UVf-VE",
			"style": "embedMediaStyle",
			"layout": "embedMediaLayout"
		}],
		"layout": "embedLayout",
		"style": "embedStyle"
	}],
	"bundlesToUrls": {}
}

You can also install it as a dependency:

npm install distro-mic
import { format } from 'distro-mic';

const html = '<p>Article HTML</p>';
const output = format(html);

Distro →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.