Created
September 4, 2016 13:32
-
-
Save ScottHelme/1cbb223f022824a6e34a9a0f534e1daf to your computer and use it in GitHub Desktop.
Update Ghost 0.10.0 to use Google AMP Cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/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