Answer the question
In order to leave comments, you need to log in
How to link Nuxt and CMS?
The cms is craft . It is by default built on twig templates, from which html is subsequently generated. In my case, the element-api plugin is used , which allows craft to be used as headless-cms. The number of twig templates in this case is reduced to one, the index one, which, in addition to the head section, contains a div#app where the application is supposed to be mounted.
At the root of craft cms there is a web folder, which contains index.php with the following content
<?php
// Set path constants
define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');
// Load Composer's autoloader
require_once CRAFT_VENDOR_PATH.'/autoload.php';
// Load dotenv?
if (class_exists('Dotenv\Dotenv') && file_exists(CRAFT_BASE_PATH.'/.env')) {
Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
}
// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
/** @var craft\web\Application $app */
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();
new Vue({ render: h => h(App) }).$mount('#app')
Answer the question
In order to leave comments, you need to log in
The advice is simple - learn.
Everything is very chaotic, nothing is clear. How it works, how it's configured...
You can turn on the fortune teller mode. Someone will do this and will give advice. Maybe they will point you in the right direction ...
Let's start first.
What is "headless-cms"? it is essentially a cms in API mode. Receives a request, returns raw data. Most often in json format.
What follows from this?
This means you have two applications. Server part on cms. And the client side on vue.
The first works on php, the second on nodejs.
So you must raise two servers (software) on your server (machine). One will process requests for data (API/cms), the other will hang on the default port 80 (your front on VUE) and take data from the first one.
As for nuxt, it can work in SSR modes and without it. If not, then it all comes down to copying your index.html from the build into the main CMS template. If with SSR, then you have to raise additional. nodejs server and resolve requests with nginx. 80th port on nodejs, custom - on php cms.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question