I am coding a blog using Nuxt.js and ButterCMS API for backend and for display posts.
I am loading some JavaScript code for display my posts correctly, that is working very well.
The problem is that when I navigate via the menu (so via NuxtLink), the script of each page is not loaded. When I refresh the page, everything is working correctly. I don't want to make a script that refresh automatically the page when clicking on an item of the menu because it will remove Nuxt transition between pages.
I already seen several posts with the same problem as mind on GitHub and Stack Overflow, but without solution that was working for me.
Here is my code that is directly in script tag in a Vue page :
import { butter } from "~/plugins/buttercms";
butter.page.retrieve("*", "simple-page").then(() => {
const createScript1 = document.createElement("script");
createScript1.src = "../../script/post-informations.js";
document.head.appendChild(createScript1);
});
const createScript2 = document.createElement("script");
createScript2.src = "https://sibforms.com/forms/end-form/build/main.js";
document.head.appendChild(createScript2);