Skip to content
Β 
Β 

Latest commit

Β 

History

56 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Netlify Status

AstroπŸš€5 + a✌🏼peaceofmind

Features:

  • βœ… HTML5 semantics
  • βœ… Images optimized at build time by πŸš€automatio
  • βœ… <picture> element respose

WARNING.

Despite this repo being public, it doesn't mean that all these assets are open-source and/or copyright free, or even that you may use any of them.

Please, ask for permission first, by contacting us: info@junglestar.org

All photos Β© Binocle. All rights reserved. Thanks, Junglestar team.

ProjectπŸ’₯Structure

my-astro-site/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ pages/           # Routes - each .astro = a page
β”‚   β”‚   β”œβ”€β”€ index.astro   # Homepage (/)
β”‚   β”‚   └── about.astro   # About page (/about)
β”‚   β”œβ”€β”€ layouts/          # Reusable page layouts
β”‚   β”‚   └── Layout.astro
β”‚   β”œβ”€β”€ components/       # Reusable components
β”‚   β”‚   └── Card.astro
β”‚   β”œβ”€β”€ styles/          # CSS files (processed by Vite)
β”‚   β”‚   └── global.css
β”‚   └── scripts/         # JS files (processed & optimized by Vite!)
β”‚       └── main.js
β”œβ”€β”€ public/              # Static assets (served as-is, NO processing)
β”‚   β”œβ”€β”€ favicon.ico
β”‚   └── legacy-libs/     # Old libraries that shouldn't be processed
β”‚       └── jquery.min.js
β”œβ”€β”€ .zed/                # Zed editor settings
β”‚   └── settings.json
β”œβ”€β”€ astro.config.mjs     # Config file (NOT .ts!)
β”œβ”€β”€ package.json
β”œβ”€β”€ pnpm-lock.yaml      # PNPM lock file
└── biome.json          # Biome config (formats JS/CSS)

CoreπŸ’₯Files

astro.config.mjs

import { defineConfig } from 'astro/config';

export default defineConfig({
  // Keep it simple - no config needed for basic sites
});

biome.json (formats JS/CSS, skips .astro)

{
  "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
  "files": {
    "include": ["src/**/*.js", "src/**/*.css", "*.mjs"],
    "ignore": ["dist", "node_modules", ".astro"]
  },
  "formatter": {
    "enabled": true,
    "indentStyle": "space",
    "indentWidth": 2,
    "lineWidth": 100
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "javascript": {
    "formatter": {
      "quoteStyle": "single",
      "semicolons": "asNeeded"
    }
  },
  "overrides": [
    {
      "include": ["*.astro"],
      "formatter": {
        "enabled": false
      },
      "linter": {
        "enabled": false
      }
    }
  ]
}

.zed/settings.json (Zed editor config)

{
  "format_on_save": "on",
  "formatter": {
    "language_server": {
      "name": "biome"
    }
  },
  "lsp": {
    "biome": {
      "settings": {
        "require_config_file": true
      }
    }
  }
}

πŸš€ src/layouts/Layout.astro

---
// JavaScript here - NOT TypeScript!
const { title } = Astro.props;
---

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{title}</title>
  <link rel="stylesheet" href="/src/styles/global.css">
</head>
<body>
  <slot /> <!-- Page content goes here -->
  <!-- <script src="/scripts/main.js"></script> -->
</body>
</html>

πŸš€ src/pages/index.astro

---
// JavaScript in the frontmatter
import Layout from '../layouts/Layout.astro';
import Card from '../components/Card.astro';

const pageTitle = "Home";
const items = ['First', 'Second', 'Third'];
---

<Layout title={pageTitle}>
  <h1>Welcome</h1>

  <!-- Use JavaScript expressions -->
  <ul>
    {items.map(item => <li>{item}</li>)}
  </ul>

  <!-- Use components -->
  <Card title="Hello" />

  <!-- Inline scripts if needed -->
  <script>
    console.log('This runs on the client');
  </script>
</Layout>

πŸš€ src/components/Card.astro

---
// Component JavaScript
const { title, href = "#" } = Astro.props;
---

<div class="card">
  <h3>{title}</h3>
  <a href={href}>Learn more β†’</a>
</div>

<style>
  /* Scoped CSS - only affects THIS component */
  .card {
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 8px;
  }
</style>

πŸš€ src/styles/global.css

/* Regular CSS file */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

src/scripts/main.js

// JavaScript in src/ gets processed & optimized by Vite!
// You can use ES modules, imports, etc.
import { utils } from './utils.js';

document.addEventListener('DOMContentLoaded', () => {
  console.log('Site loaded!');
  utils.init();
});

KeyπŸ’₯Concepts

1. Astro πŸš€ Components = HTML + TS + CSS

---
// JavaScript goes here (runs at build time)
const data = "Hello";
---

<!-- HTML template -->
<div>{data}</div>

<style>
  /* Scoped CSS */
</style>

<script>
  // Client-side JavaScript
</script>

2. Import Your Existing JS/TS/CSS

---
// Import from src/ for processing
import '../scripts/main.js';
import '../styles/global.css';
---

<!-- For scripts in src/ (processed by Vite) -->
<script src="../scripts/main.js"></script>

<!-- For scripts in public/ (NO processing, needs is:inline) -->
<script is:inline src="/unprocessed-legacy.js"></script>

3. Static Assets in public/ (NO πŸš€ processing)

public/
β”œβ”€β”€ images/logo.png     β†’ /images/logo.png
β”œβ”€β”€ fonts/custom.woff2  β†’ /fonts/custom.woff2
└── libs/jquery.forget.it β†’ /libs/jquery.rip.js (already expired)

⚠️ Important:

  • src/ = Vite processes & optimizes your JS/CSS
  • public/ = Served as-is, no processing at all

4. Dynamic πŸš€ Routes

---
// src/pages/blog/[slug].astro
export function getStaticPaths() {
  return [
    { params: { slug: 'post-1' } },
    { params: { slug: 'post-2' } },
  ];
}

const { slug } = Astro.params;
---

<h1>Post: {slug}</h1>

Migration from Jekyll/Static Site

Quick πŸš€ Start

# Create new Astro project
pnpm create astro@latest my-site -- --template minimal --no-install --no-git

# Go to project
cd my-site

# Install dependencies
pnpm install

# Install Biome (faster, no Prettier needed)
pnpm add -D @biomejs/biome
pnpm biome init

# Start dev server
pnpm dev

Migration πŸš€ Steps

  1. Copy your static files to public/
  2. Convert HTML files to .astro files in src/pages/
  3. Extract common HTML to src/layouts/Layout.astro
  4. Keep using your existing JS/CSS - just import them!

Package Scripts (package.json)

{
  "scripts": {
    "dev": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "format": "biome format --write ./src",
    "lint": "biome lint ./src"
  }
}

Before (Jekyll/Static)

<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>My Site</h1>
  <script src="script.js"></script>
</body>
</html>

After πŸš€

---
// src/pages/index.astro
---

<html>
<head>
  <link rel="stylesheet" href="/style.css">
</head>
<body>
  <h1>My Site</h1>
  <script src="/script.js"></script>
</body>
</html>

That's it, dude!

Well, from > 0.2.x It's TS, Old JS has been refactored with TS!

About

Astro port of Jekyll BINOCLE

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages