Skip to content

Instantly share code, notes, and snippets.

@ScottHelme
Created September 4, 2016 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScottHelme/1cbb223f022824a6e34a9a0f534e1daf to your computer and use it in GitHub Desktop.
Save ScottHelme/1cbb223f022824a6e34a9a0f534e1daf to your computer and use it in GitHub Desktop.
Update Ghost 0.10.0 to use Google AMP Cache
/var/www/ghost/core/server/apps/amp/lib/helpers/amp_content.js
// make relative URLs abolute
html = makeAbsoluteUrl(html, config.url, post.url).html();
html = html.replace("https://scotthelme.co.uk/content/images/", "https://cdn.ampproject.org/i/s/scotthelme.co.uk/content/images/");
/var/www/ghost/core/server/data/meta/amp_url.js
if (_.includes(context, 'post') && !_.includes(context, 'amp')) {
var cacheUrl = config.urlJoin(config.getBaseUrl(false), getUrl(data, false)) + 'amp/';
cacheUrl = cacheUrl.replace("https://scotthelme.co.uk", "https://cdn.ampproject.org/c/s/scotthelme.co.uk");
return cacheUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment