D
D
Dima Pautov2021-01-26 19:05:02
Accelerated Mobile Pages
Dima Pautov, 2021-01-26 19:05:02

How to properly include @nuxtjs/amp module in a project?

Good evening! There was a need to create amp pages for a site on nuxt.js
Googled, found the module .

Connected in nuxt.config.js

// ...
modules: [
  // ...
  '@nuxtjs/amp'
],
amp: {
  origin: process.env.BASE_URL,
  css: '@/assets/styles/pages/amp-recipes.scss',
  routeAliases: [
    '/recipes'
  ]
},
// ...


Created an amp.vue template in the layout folder :
<template>
  <amp-body>
    <h1>AMP</h1>
    <Nuxt />
  </amp-body>
</template>


The pages directory for the specified alias looks like this:
recipes->index.vue
recipes->_slug.vue


Indicated for the recipes->index.vueproperty ampLayout: 'amp'
Indicated for the recipes->_slug.vueproperty We ampLayout: 'amp'

check by following this path:
http://localhost:3000/amp/recipes/
It works, everything flew, the AMP

header appeared
http://localhost:3000/amp/recipes/какой-то слаг
.

I don’t understand what’s the matter, the dock and Google have already searched the whole thing, dug the insides of the module itself in the node_modules folder , but I didn’t find any special answers there either, I don’t understand anything, what did I miss?

And also, is it possible to create a separate amp template for the page and specify it somehow? For to produce a lot of conditions v-if="$isAMP"in the 1st template is not the best idea.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question