rsnext/packages/next/next-server/server/optimize-amp.ts

14 lines
330 B
TypeScript
Raw Normal View History

export default async function optimize(
html: string,
config: any
): Promise<string> {
let AmpOptimizer
try {
2020-03-29 21:27:06 +02:00
AmpOptimizer = require('next/dist/compiled/ampproject--toolbox-optimizer')
} catch (_) {
return html
}
const optimizer = AmpOptimizer.create(config)
return optimizer.transformHtml(html, config)
}