23
loading...
This website collects cookies to deliver better user experience
./vendor/bin/sail up -d
http://localhost
. Open this URL on your browser and you'll see a page like this:ln -s ./vendor/bin/sail sail
chmod +x sail
./sail artisan
npm
command is available as a shortcut with Laravel Sail:./sail npm install
./sail npm install -D tailwindcss postcss autoprefixer
./sail npx tailwindcss init
webpack.mix.js
file (located at the root of your application) and include tailwindcss
as a postCss plugin. This is how your mix.js
definition should look like when you're finished:mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
]);
tailwind.config.js
file to include the paths to all your template resources. The following example will include all blade templates and JS files in your resources
folder:module.exports = {
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
],
theme: {
extend: {},
},
plugins: [],
}
@tailwindcss
component layers into your application's CSS. Open the resources/css/app.css
file and include the following content:@tailwind base;
@tailwind components;
@tailwind utilities;
./sail npm run watch
CTRL
+C
.index.blade.php
in your resources/views
folder:<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My DEV Blog</title>
<meta name="description" content="My DEV Blog">
<meta name="author" content="Sourcegraph">
<meta property="og:title" content="A headless blog in Laravel">
<meta property="og:type" content="website">
<meta property="og:url" content="https://github.com/sourcegraph-community/laravel-dev-blog">
<meta property="og:description" content="A demo Laravel blog">
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body class="bg-gradient-to-r from-blue-600 via-pink-500 to-purple-900">
<div class="container text-white mx-auto mt-6">
<div class="grid grid-cols-3 gap-4">
<div>
<h1 class="text-3xl">My DEV Blog</h1>
</div>
<div class="col-span-2 text-right">
menu
</div>
</div>
</div>
<div class="container mx-auto px-6 py-10 bg-gray-100 my-10 text-gray-600 rounded-md shadow-md">
<div class="grid grid-cols-4 gap-4">
<div class="col-span-3">
<div class="mb-10">
<img src="https://picsum.photos/1000/420" alt="Post header image" class="rounded-lg my-4"/>
<h1 class="text-3xl">This is the title of my first post</h1>
<p>This is the description bnablab alba lbal ablabla blab al.</p>
</div>
<div class="my-10">
<img src="https://picsum.photos/1000/420?sjdj" alt="Post header image" class="rounded-lg my-4"/>
<h1 class="text-3xl">This is the title of my second post</h1>
<p>This is the description bnablab alba lbal ablabla blab al.</p>
</div>
</div>
<div>
<h2 class="text-gray-400 text-xl">Categories</h2>
<ul>
<li><a href="#">Linux</a></li>
<li><a href="#">PHP</a></li>
<li><a href="#">Development</a></li>
<li><a href="#">Devops</a></li>
<li><a href="#">Career</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
asset
call, the rest is purely HTML and CSS styled with TailwindCSS descriptive classes.routes/web.php
file and update your main route definition so that it renders your new template instead of the default Laravel welcome page. This is how the file should look like once you're done:Route::get('/', function () {
return view('index');
});