Sure! Here is an example code for creating a landing page for a shoe website using the MERN stack and Tailwind CSS:
- Install the necessary dependencies:
npm install express react react-dom mongoose tailwindcss
- Create a server.js file:
const express = require('express');
const app = express();
const mongoose = require('mongoose');
app.use(express.static('public'));
mongoose.connect('mongodb://localhost:27017/shoe_website', { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => {
console.log('Connected to MongoDB');
})
.catch((error) => {
console.log('Error connecting to MongoDB:', error);
});
app.get('/', (req, res) => {
res.sendFile('public/index.html');
});
const port = 3000;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
- Create a public/index.html file and add the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shoe Website</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<div id="app"></div>
<script src="/bundle.js"></script>
</body>
</html>
- Create a src/index.js file and add the following code:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('app'));
- Create a src/App.js file and add the following code:
import React from 'react';
const App = () => {
return (
<div className="bg-gray-100 h-screen flex items-center justify-center">
<div className="bg-white p-8 rounded-md shadow-md">
<h1 className="text-4xl font-bold">Welcome to Shoe Website</h1>
<p className="text-xl mt-4">Browse our collection of shoes and find your perfect pair!</p>
</div>
</div>
);
};
export default App;
- Create a tailwind.config.js file and add the following code:
module.exports = {
purge: [
'./public/**/*.html',
'./src/**/*.js',
],
darkMode: false,
theme: {
extend: {},
},
variants: {},
plugins: [],
}
- Create a styles.css file in your public folder and add the following code:
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
- Run the server using the command:
node server.js
Now, the landing page of the shoe website should be accessible at http://localhost:3000. You can customize the styles and add more components as per your requirements.