I created my resume on https://dev.sambarnades.com using a Bootstrap model.
Now, i would want to re-adapt that website and power it on Netlify with Sanity as headless CMS in order to easily & visually modify it through Netlify.
I created a react-vite app thanks to :
npm create vite@latest
Then, I copied & past the content, adapting it to .jsx format.
But it seems the former script tags aren’t read by this new vite app format.
index.html (where is pointing the React app.jsx)
<body class="index-page">
<main id="root"></main>
<!-- Vendor JS Files -->
<script src="src/assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="src/assets/vendor/aos/aos.js"></script>
<script src="src/assets/vendor/typed.js/typed.umd.js"></script>
<script src="src/assets/vendor/purecounter/purecounter_vanilla.js"></script>
<script src="src/assets/vendor/waypoints/noframework.waypoints.js"></script>
<script src="src/assets/vendor/glightbox/js/glightbox.min.js"></script>
<script src="src/assets/vendor/imagesloaded/imagesloaded.pkgd.min.js"></script>
<script src="src/assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="src/assets/vendor/swiper/swiper-bundle.min.js"></script>
<!-- Main JS File -->
<script src="src/assets/js/template.js"></script>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
app.jsx (where I copied my content.)
function App() {
return (
<>
<header id='header' className='header d-flex flex-column justify-content-center'>
<i className='header-toggle d-xl-none bi bi-list'></i>
... all the code ...
</div>
</div>
</footer>
<a href="#" id="scroll-top" className="scroll-top d-flex align-items-center justify-content-center"><i className="bi bi-arrow-up-short"></i></a>
</>
)
}
export default App
I should see the exact same content as on https://dev.sambarnades.com but instead of it, I only see this picture & blank content. It seems that all the content which is driven by the <script>
tags is not interpreted.
I will be very glad to have ideas & advice about this issue. Thanks!
2
Answers
I found the solution.
I encapsulate all the scripts url into constants in my app.jsx & refer them into an array.
Then I mapped the array to inject the Javascript at the end of the code.
You a are missing a slash in the beginning of the src path;
And your folder structure has to be something like:
And another way is to load inside the index.js or main.js file
Also see this related topic