All Projects → jhukdev → 11tyby

jhukdev / 11tyby

Licence: MIT License
Simple 11ty setup using TypeScript, SASS, Preact with partial hydration, and other useful things. Aims to provide the DX of Gatsby, but using 11ty!

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
SCSS
7915 projects

Projects that are alternatives of or similar to 11tyby

Microsite
Do more with less JavaScript. Microsite is a smarter, performance-obsessed static site generator powered by Preact and Snowpack.
Stars: ✭ 632 (+1563.16%)
Mutual labels:  static-site-generator, preact, css-modules, static-site
Netlify Cms React Starter
A starter project for creating lightning-fast, offline-first websites with Netlify-CMS and React
Stars: ✭ 78 (+105.26%)
Mutual labels:  static-site-generator, starter, static-site
frontenso-11ty-starter
Production-ready 11ty+Gulp+Webpack Starter that features Nunjucks, SASS, TailwindCSS (with JIT complier), and ESNext.
Stars: ✭ 24 (-36.84%)
Mutual labels:  starter, eleventy, 11ty
eleventy-plugin-cloudinary
An Eleventy shortcode that allows you to add an image from your cloudinary account
Stars: ✭ 28 (-26.32%)
Mutual labels:  static-site-generator, eleventy, 11ty
Next Js Blog Boilerplate
🚀 Nextjs Blog Boilerplate is starter code for your blog based on Next framework. ⚡️ Made with Nextjs, TypeScript, ESLint, Prettier, PostCSS, Tailwind CSS.
Stars: ✭ 134 (+252.63%)
Mutual labels:  static-site-generator, starter, static-site
bymattlee-11ty-starter
A starter boilerplate powered by 11ty, Sanity, Gulp, Tailwind CSS, rollup.js, Alpine.js and Highway.
Stars: ✭ 27 (-28.95%)
Mutual labels:  static-site-generator, eleventy, 11ty
nuxt-starter-netlify-cms
Example nuxt + netlify cms project. Nuxt port of Gatsby starter app.
Stars: ✭ 13 (-65.79%)
Mutual labels:  static-site-generator, starter
aleksandrhovhannisyan.com
My online resume and blog, created with 11ty, Sass, and JavaScript.
Stars: ✭ 50 (+31.58%)
Mutual labels:  static-site, 11ty
jekyll-skeleton
Scaffolding to start with a Jekyll website
Stars: ✭ 27 (-28.95%)
Mutual labels:  static-site-generator, static-site
tinystatic
A tiny static website generator which is flexible and easy to use
Stars: ✭ 36 (-5.26%)
Mutual labels:  static-site-generator, static-site
rocket
The modern web setup for static sites with a sprinkle of JavaScript
Stars: ✭ 169 (+344.74%)
Mutual labels:  static-site-generator, eleventy
jschr.io
The static website generator service behind jschr.io.
Stars: ✭ 70 (+84.21%)
Mutual labels:  static-site-generator, static-site
jigsaw-blog-template
Starter template for a blog, using Jigsaw by Tighten
Stars: ✭ 75 (+97.37%)
Mutual labels:  static-site-generator, static-site
hugo-initio
Hugo Theme port of Initio bootstrap template by GetTemplate
Stars: ✭ 58 (+52.63%)
Mutual labels:  static-site-generator, static-site
smix-eleventy-starter
A standards-respecting starter kit for Eleventy. Go Indie.
Stars: ✭ 108 (+184.21%)
Mutual labels:  eleventy, 11ty
nera
A lightweight static site generator
Stars: ✭ 12 (-68.42%)
Mutual labels:  static-site-generator, static-site
smol-11ty-starter
Extremely minimal Eleventy starter to kickstart a simple multi-page site / a nearly opinionless foundation to continue building on.
Stars: ✭ 61 (+60.53%)
Mutual labels:  eleventy, 11ty
contentz
Create Content, Get a Highly Optimized Website
Stars: ✭ 57 (+50%)
Mutual labels:  static-site-generator, static-site
stacy
Website generator that combines content from Contentful CMS with Handlebars templates and publishes the website in Amazon S3.
Stars: ✭ 24 (-36.84%)
Mutual labels:  static-site-generator, static-site
nextjs-blog-starter-kit
NextJS Blog + Contentful Typescript Starter kit with Static Export 🚀
Stars: ✭ 56 (+47.37%)
Mutual labels:  starter, static-site

11tyby

An organised 11ty boilerplate to get you up and running fast. Features TypeScript, native JSX support via Preact, CSS Modules with SASS, a well defined webpack config for great DX, and all pre-optimised for performance.

Demo: https://11tyby.netlify.app/

Why

Getting setup with the necessary tooling to handle TypeScript, JSX, dynamic imports, SASS etc is time consuming. This project also has partial hydration to reduce the amount of code shipped to your users.

Structure

The project is structured via the module pattern, files are grouped via feature, e.g ./src/modules/home. This allows you to better future proof your application as it grows, and localise code where it's needed. Your page *.11ty.tsx files reside within their relevant feature folder, and export a permalink property for you to define their url structure, e.g:

module.exports = {
  render: Page,
  data: () => ({
    permalink: '/my-feature/index.html',
  }),
};

Styling

11tyby comes pre-setup with support for CSS Modules and SASS. You have two options to import styles, globally or localised. To convert a SASS or CSS file into a CSS Module, you'll need to apply a .module suffix to your file, e.g login.module.css. You can then import this directly into a component:

import style from './login.module.scss';

/*[...]*/

function Login() {
  return <form class={style.form}>/*[...]*/</form>;
}

To import styles globally, just add a non return import statement to the file you wish to load them from, e.g:

import './global.css';

/*[...]*/

To apply the generated style sheet to a page, you'll need to add a cssPath property within the data object exported from your *.11ty.tsx files, e.g:

function Page() {
  return <main class={style.wrapper}>{/*[...]*/}</main>;
}

/*[...]*/

module.exports = {
  render: Page,
  data: () => ({
    permalink: 'index.html',
    cssPath: 'login/login.11ty.css', // <----
  }),
};

The path will match the respective module folder, and the name will mirror that of your *.11ty.tsx file name but with a CSS extension.

Hydration

11tyby includes a package dedicated to applying partial hydration. This works as an HOC, wrapping the component you wish to hydrate on the client. You can apply this as follows:

import { define } from 'preactement';

/*[...]*/

function MainForm() {
  return <form>/*[...]*/</form>;
}

/*[...]*/

const Form = define('main-form', () => MainForm);

/*[...]*/

export { Form };

It's recommended that you create components within their own folder, and apply this function in an index.ts file within. That way you can seperate any "transforms" the component might need at runtime with the component itself, you can see an example here.

Once you have a hydrated component, you'll need to import it into an "Entry" file. These are suffixed with .entry, and must be placed within their respective module folder, e.g ./src/home/home.entry.ts.

The entry file needs to import your hydrated components, e.g:

import '@/modules/home/components/form';

This file is then referenced within your *.11ty.tsx file by passing it into the data object exported from your component, e.g:

/*[...]*/
function Page() {
  return <main>{/*[...]*/}</main>;
}

/*[...]*/

module.exports = {
  render: Page,
  data: () => ({
    permalink: 'index.html',
    jsPath: 'home/home.entry.js', // <----
  }),
};

For a working example, take a look at the home module here.

Data

All official 11ty methods to gather data from an API or otherwise, will work here. There are many great examples of how to do this in the official 11ty documentation, including the use of GraphQL: https://www.11ty.dev/docs/data-js/.

To define global data, add either JSON, JS or TypeScript files to the ./src/data folder. These will then be parsed by 11ty and added via the data cascade. You can access these directly in your .11ty.ts* files.

For example, if you were to add a global.ts file to ./src/data, you would access this via a global property in your pages argument object:

interface IProps {
  global: {
    title: string;
  };
}

/*[...]*/

function Page({ global }: IProps) {
  return (
    <main>
      <h1>{global.title}</h1>
    </main>
  );
}

To add local data, e.g data specific to a module, add a file suffixed with .data within the relevant module folder. This will then be accessible in exactly the same way as shown above, but only for that page. For example, if you added home.data.ts to ./src/modules/home, your home page 11ty.tsx file would have access to the values held within that data file.

Installation

1. Clone or download the repository

git clone [email protected]:jahilldev/11tyby.git

2. Install the project dependencies

yarn

Development

yarn start

Build production

yarn build
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].