Giter VIP home page Giter VIP logo

11ty-tailwind's Introduction

What I learned

Getting Started

install eleventy

cd 11ty-tailwind
### create package.json
npm init -y

### install

npm i -D @11ty/eleventy

verify 11ty working

$ npx eleventy
[11ty] Wrote 0 files in 0.01 seconds (v2.0.1)

create first file index.html, and run npx eleventy

install tailwind

tailwind cli

npm install -D tailwindcss
npx tailwindcss init
npx tailwindcss -i ./tailwind.css -o ./_site/css/styles.css --watch

add in index.html

<link rel="stylesheet" href="/css/styles.css" />

dev


npx eleventy --serve

### check localhost:8080

config

Passthrough File Copy

tell 11ty to copy things to "_site" output folder

create .eleventy.js in root folder, and add content

module.exports = function (eleventyConfig) {
  // Output directory: _site
  eleventyConfig.addPassthroughCopy("./style.css")
}

now create style.css under root, this will automatically copied to "_site", and affect the style of site immediately.

templating njk

change index.html to index.njk

---
layout: "layouts/base.njk"
---

<h1 class="text-4xl font-bold text-blue-500">Hello world!</h1>

layout

create folder "_includes" create base layout file "layouts/base.njk" add html boilplate code here.

  <body>
  {{ content | safe }}
  </body>

macro

like react component. create a file /components/service-macro.njk

{% macro service(para1,para2,....) %}
html snippet
{% endmacro %}

to use the macro, in /sections/services.njk

{% import 'components/service-macro.njk' as macro %}
{{ macro.service('shadow-sm','bg-cyan-400', 'title', 'paragragh') }}
{{ macro.service('shadow-lg','bg-red-400', 'title', 'paragragh') }}
{{ macro.service('shadow-sm','bg-cyan-400', 'title', 'paragragh') }}

deploy

config

add in package.json

  "scripts": {
    "dev": "npx tailwindcss -i ./tailwind.css -o ./_site/css/styles.css --watch",
    "prod": "npx tailwindcss -i ./tailwind.css -o ./_site/css/styles.css"
  },

github

run git init

create file .gitignore

/node_modules
/_site

push to github

create netlify cli

npm install -D netlify-cli
npx netlify init

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.