Skip to content

Commit d652a9f

Browse files
authored
Merge pull request #98 from tighten/nd/update-template
Update template (Vite, Tailwind 4 and more)
2 parents b160b04 + e8fd12d commit d652a9f

21 files changed

Lines changed: 126 additions & 308 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/source/assets/build/
44
/vendor/
55
.DS_Store
6+
hot

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

package.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
{
22
"private": true,
3+
"type": "module",
34
"scripts": {
4-
"dev": "mix",
5-
"watch": "mix watch",
6-
"prod": "mix --production"
5+
"dev": "vite",
6+
"build": "vite build",
7+
"prod": "vite build --mode production"
78
},
89
"devDependencies": {
9-
"autoprefixer": "^10.4.13",
10-
"axios": "^0.21.1",
11-
"browser-sync": "^2.27.4",
12-
"browser-sync-webpack-plugin": "^2.3.0",
13-
"fast-glob": "^3.2.12",
1410
"fuse.js": "^6.4.6",
15-
"highlight.js": "^11.7.0",
16-
"laravel-mix": "^6.0.39",
17-
"laravel-mix-jigsaw": "^2.0.0",
18-
"postcss": "^8.4.21",
19-
"postcss-import": "^14.0.2",
20-
"tailwindcss": "^3.2.4",
11+
"@tighten/jigsaw-vite-plugin": "^1.0.0",
12+
"vite": "^6.2.1",
13+
"tailwindcss": "^4.1.0",
14+
"@tailwindcss/vite": "^4.1.8",
2115
"alpinejs": "^3.14.1"
2216
}
2317
}

readme.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ This starter template includes samples of common page types, and comes pre-confi
1616

1717
- A fully responsive navigation bar
1818
- [Tailwind CSS](https://tailwindcss.com/), a utility CSS framework that allows you to customize your design without touching a line of CSS
19-
- [Purgecss](https://www.purgecss.com/) to remove unused selectors from your CSS, resulting in smaller CSS files
20-
- Syntax highlighting using [highlight.js](https://highlightjs.org/)
19+
- Syntax highlighting using [Prism](https://prismjs.com/)
2120
- A script that automatically generates a `sitemap.xml` file
2221
- A custom 404 page
23-
- A component for accepting signups for a [Mailchimp](https://mailchimp.com/) newsletter
2422
- A sample contact form
2523
- A search bar powered by [Fuse.js](http://fusejs.io/) and [Alpine.js](https://alpinejs.dev/), which indexes your content automatically and requires zero configuration
2624

@@ -71,13 +69,11 @@ featured: true
7169

7270
### Adding Assets
7371

74-
Any assets that need to be compiled (such as JavaScript, Less, or Sass files) can be added to the `source/_assets/` directory, and Laravel Mix will process them when running `npm run dev` or `npm run prod`. The processed assets will be stored in `/source/assets/build/` (note there is no underscore on this second `assets` directory).
75-
76-
Then, when Jigsaw builds your site, the entire `/source/assets/` directory containing your built files (and any other directories containing static assets, such as images or fonts, that you choose to store there) will be copied to the destination build folders (`build_local`, on your local machine).
72+
Any assets that need to be compiled, such as JavaScript or CSS using Tailwind, can be added to the `source/_assets/` directory. Vite will process them when running `npm run dev` or `npm run build`, and the processed assets will be stored in `/build_local` or `/build_production`, respectively.
7773

7874
Files that don't require processing (such as images and fonts) can be added directly to `/source/assets/`.
7975

80-
[Read more about compiling assets in Jigsaw using Laravel Mix.](http://jigsaw.tighten.co/docs/compiling-assets/)
76+
[Read more about compiling assets in Jigsaw using Vite.](http://jigsaw.tighten.co/docs/compiling-assets/)
8177

8278
---
8379

@@ -86,10 +82,9 @@ Files that don't require processing (such as images and fonts) can be added dire
8682
Now that you’ve edited your configuration variables and know how to customize your styles and content, let’s build the site.
8783

8884
```bash
89-
# build static files with Jigsaw
90-
./vendor/bin/jigsaw build
91-
92-
# compile assets with Laravel Mix
93-
# options: dev, prod
85+
# run development server
9486
npm run dev
87+
88+
# build static files with Vite
89+
npm run build
9590
```

source/_assets/css/base.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ code {
2525
@apply py-px;
2626
@apply text-sm;
2727
@apply bg-gray-300;
28-
@apply rounded;
28+
@apply rounded-sm;
2929
}
3030

3131
code.hljs {
@@ -117,7 +117,7 @@ ul {
117117
p {
118118
@apply my-3;
119119

120-
@screen md {
120+
@media (width >= theme(--breakpoint-md)) {
121121
@apply my-6;
122122
}
123123
}
@@ -128,8 +128,8 @@ pre {
128128
@apply text-base;
129129
@apply bg-gray-200;
130130
@apply leading-loose;
131-
@apply rounded;
132-
@apply shadow;
131+
@apply rounded-sm;
132+
@apply shadow-sm;
133133
@apply overflow-x-auto;
134134

135135
& code {

source/_assets/css/mailchimp.css

Lines changed: 0 additions & 73 deletions
This file was deleted.

source/_assets/css/main.css

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,50 @@
1-
@import 'tailwindcss/base';
2-
@import 'tailwindcss/components';
1+
@import "tailwindcss";
32

4-
/* Code syntax highlighting, powered by https://highlightjs.org */
5-
@import 'highlight.js/styles/a11y-light.css';
3+
@import './base.css' layer(components);
4+
@import './blog.css' layer(components);
65

7-
@import 'base';
8-
@import 'mailchimp';
9-
@import 'blog';
6+
@layer base {
7+
:root {
8+
--font-sans: "Nunito Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
9+
"Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
10+
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
1011

11-
@import 'tailwindcss/utilities';
12+
--shadow-search: 0 -1px 27px 0 rgba(0, 0, 0, 0.04), 0 4px 15px 0 rgba(0, 0, 0, 0.08);
13+
}
14+
15+
*,
16+
::after,
17+
::before,
18+
::backdrop,
19+
::file-selector-button {
20+
border-color: var(--color-gray-200, currentcolor);
21+
}
22+
23+
body {
24+
font-family: var(--font-sans);
25+
}
26+
}
27+
28+
@layer utilities {
29+
.shadow-search {
30+
box-shadow: var(--shadow-search);
31+
}
32+
}
33+
34+
/* Syntax Highlight by Prism */
35+
/* https://prismjs.com/ */
36+
37+
/* You can customize the theme of the Prism syntax highlighter below. Adjust colors, backgrounds, and styles as needed for your site. */
38+
39+
:not(pre) > code[class*="language-"],
40+
pre[class*="language-"] {
41+
background: #e5e7eb;
42+
}
43+
44+
.token.operator,
45+
.token.entity,
46+
.token.url,
47+
.language-css .token.string,
48+
.style .token.string {
49+
background: transparent;
50+
}

source/_assets/js/main.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
window.axios = require('axios');
21
import Alpine from "alpinejs";
32
import Fuse from "fuse.js";
43

54
window.Fuse = Fuse;
65
window.Alpine = Alpine;
76

87
Alpine.start();
9-
10-
import hljs from 'highlight.js/lib/core';
11-
12-
// Syntax highlighting
13-
hljs.registerLanguage('bash', require('highlight.js/lib/languages/bash'));
14-
hljs.registerLanguage('css', require('highlight.js/lib/languages/css'));
15-
hljs.registerLanguage('html', require('highlight.js/lib/languages/xml'));
16-
hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'));
17-
hljs.registerLanguage('json', require('highlight.js/lib/languages/json'));
18-
hljs.registerLanguage('markdown', require('highlight.js/lib/languages/markdown'));
19-
hljs.registerLanguage('php', require('highlight.js/lib/languages/php'));
20-
hljs.registerLanguage('scss', require('highlight.js/lib/languages/scss'));
21-
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml'));
22-
23-
document.querySelectorAll('pre code').forEach((block) => {
24-
hljs.highlightElement(block);
25-
});
26-
Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
1-
<div class="flex justify-center lg:-mx-12 my-12 p-6 md:px-12 bg-gray-200 border border-gray-400 text-sm md:rounded shadow">
2-
<!-- Begin Mailchimp Signup Form -->
3-
<div id="mc_embed_signup">
4-
<form action="https://your-mail-chimp-list-manage-url" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
5-
<div id="mc_embed_signup_scroll">
6-
<h2>Sign up for our newsletter</h2>
7-
<div class="mc-field-group">
8-
<label for="mce-EMAIL">Email Address </label>
9-
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="Email address">
10-
</div>
11-
<div id="mce-responses" class="clear">
12-
<div class="response" id="mce-error-response" style="display:none"></div>
13-
<div class="response" id="mce-success-response" style="display:none"></div>
14-
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
15-
16-
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_25582686a9fc051afd5453557_189578c854" tabindex="-1" value=""></div>
17-
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
1+
<div class="flex justify-center items-center bg-gray-200 border border-gray-400 rounded-lg p-4 md:p-8 md:px-12 my-12 shadow-sm lg:-mx-12">
2+
<form action="" method="post" class="w-full max-w-3xl">
3+
<div class="flex flex-col items-center w-full gap-3 md:gap-4">
4+
<div class="text-xl md:text-2xl font-bold text-gray-900 text-center">Sign up for our newsletter</div>
5+
<div class="flex w-full max-w-lg">
6+
<input type="email" required name="email" placeholder="Email address" class="text-sm flex-1 rounded-l-md px-3 py-3 border-none focus:ring-2 focus:ring-blue-400 focus:outline-none bg-white text-gray-700 placeholder-gray-400">
7+
<button type="submit" class="text-sm rounded-r-md px-4 md:px-8 py-3 font-medium bg-blue-400 text-white hover:bg-blue-500 transition-colors duration-150">Subscribe</button>
188
</div>
19-
</form>
20-
</div>
21-
<!--End Mailchimp Signup Form -->
9+
<div class="text-sm">Need forms? Try <a href="https://fieldgoal.io/" class="underline" target="_blank">FieldGoal</a></div>
10+
</div>
11+
</form>
2212
</div>
23-
24-
@push('scripts')
25-
<script src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
26-
<script>(function($) {
27-
window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';}(jQuery));var $mcj = jQuery.noConflict(true);
28-
</script>
29-
@endpush

source/_components/search.blade.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<div x-data="{
22
init(){
3-
window.axios('/index.json')
4-
.then(response => {
5-
this.fuse = new window.Fuse(response.data, {
6-
minMatchCharLength: 6,
7-
keys: ['title', 'snippet', 'categories'],
8-
});
3+
fetch('/index.json')
4+
.then(response => response.json())
5+
.then(data => {
6+
this.fuse = new window.Fuse(data, {
7+
minMatchCharLength: 6,
8+
keys: ['title', 'snippet', 'categories'],
99
});
10+
});
1011
},
1112
get results() {
1213
return this.query ? this.fuse.search(this.query) : [];
@@ -27,7 +28,7 @@
2728
this.query = '';
2829
this.searching = false;
2930
},
30-
}"
31+
}"
3132
x-cloak
3233
class="flex flex-1 justify-end items-center text-right px-4"
3334
>
@@ -41,8 +42,9 @@ class="absolute md:relative w-full justify-end bg-white left-0 top-0 z-10 mt-7 m
4142
id="search"
4243
x-model="query"
4344
x-ref="search"
44-
class="relative block h-10 w-full lg:w-1/2 lg:focus:w-3/4 bg-gray-100 border border-gray-500 focus:border-blue-400 outline-none cursor-pointer text-gray-700 px-4 pb-0 pt-px transition-all duration-200 ease-out bg-[url('/assets/img/magnifying-glass.svg')] bg-no-repeat bg-[0.8rem] indent-[1.2em]"
45+
class="relative block h-10 w-full lg:w-1/2 lg:focus:w-3/4 bg-gray-100 border border-gray-500 focus:border-blue-400 outline-none cursor-pointer text-gray-700 px-4 pb-0 pt-px transition-all duration-200 ease-out bg-no-repeat bg-[0.8rem] indent-[1.2em]"
4546
:class="{ 'rounded-b-none rounded-t-lg': query, 'rounded-3xl': !query }"
47+
style="background-image: url('/assets/img/magnifying-glass.svg')"
4648
autocomplete="off"
4749
name="search"
4850
placeholder="Search"

0 commit comments

Comments
 (0)