Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
amps-in-the-trunk
Advanced tools
amps-in-the-trunk will go through your HTML, use the DOM to change <img>
into <amp-img>
and add missing height / width stats.
So the main things with AMP for me were:
Most apps use a templating engine to generate their HTML. So as a developer:
<script>
tagsSo you're using express, this looks like
layout=
to specify the AMP layout rather than your normal oneres.renderAMP(view, local)
to render HTML and convert it to AMP:// Load the module and pass in any overrides
var ampsInTheTrunk = require('amps-in-the-trunk')()
// Enable the renderAMP Express middleware
app.use(ampsInTheTrunk.renderAMP);
// Handle a route by respondingwith an AMP page
router.get('/blog', function(req, res){
res.renderAMP('blog-index', {
'title': 'My Blog',
inlineStyles,
styles: [ 'style', 'articles']
});
});
amps-in-the-trunk sets images to responsive
by default. You can change that with imageOverrides
. Also most SVGs have incorrect sizing. You could fix the SVGs, or you could override them with imageOverrides
.
var imageOverrides = {
'logo.svg': {
width: 22,
height: 22,
layout: 'fixed'
},
'rss.svg': {
width: 26,
height: 16,
layout: 'fixed'
}
}
var ampsInTheTrunk = require('amps-in-the-trunk')(imageOverrides)
I tried html-to-amp but that uses html-to-article-json first and it lost images. I don't care about article.json
and I don't care about non-AMP alternative formats. I just wanted an AMP version of my HTML that didn't lose any data and would pass the AMP validator.
This is the first version of the module, created really for my own needs. I'm quite happy to take pull requests for additional features.
Because amplify
and html-to-amp
were taken and because House of Pain
FAQs
Turns HTML in Google AMP HTML. Includes express middleware.
The npm package amps-in-the-trunk receives a total of 6 weekly downloads. As such, amps-in-the-trunk popularity was classified as not popular.
We found that amps-in-the-trunk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.