Code Monkey home page Code Monkey logo

Minimal 11ty Starter

Image showing the demo website

A very minimal eleventy starter using Tailwind CSS for styling.

It features a smart navigation component that sets active states automatically.

For beginners and/or when you need a simple static site and don't want to duplicate your navigation header and set active states for the nth time.

Features

🦴 As minimal as possible
⚡️ Active states in the navigation are automatically set based on the current url.
💨 Add a couple of lines to any page and it will appear in the navigation. (Check how to below)
🗓 A very simple blog structure because why not
🍪 Example for including json data on contact page
💜 Tailwind CSS


Getting Started

1. Clone this repo

git clone [email protected]:tomreinert/minimal-11ty-tailwind-starter.git mysite

2. Change into the working directory

cd mysite

3. Install dependencies

npm install

4. Work locally

Watches for changes and serves locally on http://localhost:8080

npm run serve

5. Create a production build

npm run build

How To: Navigation

The top navigation is the only feature in this starter and lives in /src/_includes/components/navigation.njk.

It looks for the eleventyNavigation object in pages and adds them to the navigation bar. It also checks whether the site's url is in the currently opened url and highlights the navigation item accordingly. This even works for subpages. So if you're on /blog/post/ the Blog nav item will still be active.

Adding links to the navigation

Add the eleventyNavigation object to any page and it will appear in the navigation. Optionally set the order of your items. Check the 11ty docs for more information about the navigation plugin.

---
eleventyNavigation:
  key: Your Page Name
  order: 1
---

Changing the navigation item styles

The script in /_includes/components/navigation.njk checks if a navigation item is active and styles it accordingly. Let's dissect the code:

<a
 href="{{ entry.url }}"

 // Base styles for navigation items
 class="py-1 px-2 rounded mr-4 inline-block

 // Styles for the active navigation item
 {{'bg-white text-black' if entry.url in page.url

 // Styles for default navigation item
 else 'text-gray-400 hover:text-gray-100'}}">
 {{ entry.title }}
</a>

How To: Blog

Add a page in _src/blog/posts and it will appear in the post list.

Credits

Bryan L. Robinson for explaining how to create the active navigation state

https://statickit.com/guides/eleventy-tailwind - I set up the project according to this guide

https://11ty.io/

https://tailwindcss.com/

Ianiv Hojman's Projects

awesome-vue icon awesome-vue

🎉 A curated list of awesome things related to Vue.js

c-pointers icon c-pointers

I'm too bad as a C programmer, so I made a pointers example in C that I still don't understand

clio icon clio

Clio is a functional, parallel, distributed programming language.

how-to icon how-to

how to everything, from extracting a tar file to adding a git repository in an existing directory

image-classifier icon image-classifier

Convolutional Neural Network and Auto Encoder to classify ~5 types of satellite images. Built with Tensorflow.

job-interviews icon job-interviews

Repo con los desafíos de todas las pegas a las que postulé, un branch por empresa. No quedé en ninguna 💀

nnodes icon nnodes

App para postular como dev a NNodes. Usé Ruby para desarrollar y Heroku para el deploy

open-nsynth-super icon open-nsynth-super

Open NSynth Super is an experimental physical interface for the NSynth algorithm

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.