-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproducts.html
More file actions
111 lines (95 loc) · 4.67 KB
/
products.html
File metadata and controls
111 lines (95 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!-- Follow the in-page instructions to change this file -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--Change this to what you whant (This dissplys at tab)-->
<title>Cheese Factory | Products</title>
<!--Add a disscription this is what appers on the google page-->
<meta name="description"
content="Discover Cheese Factory’s handmade artisan cheeses, new seasonal flavors, and gift boxes. Freshly crafted and delivered to your door.">
<!--This is key words helps your seach apperance-->
<meta name="keywords"
content="Cheese Factory, artisan cheese, seasonal cheese, buy cheese online, British cheese, handmade dairy products">
<!--This link links to your home page (yourbissness.github.io)-->
<link rel="canonical" href="https://theorangecow.github.io/cheese/">
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/x-icon" href="https://theorangecow.github.io/cheese/images/logo/logo.ico">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
</head>
<body>
<header>
<!--The title at the top of the page-->
<h1>Cheese Factory</h1>
</header>
<nav>
<!--This is the nav bar if you change something here you have to change it in every file-->
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="products.html">Products</a>
<a href="contact.html">Contact</a>
<a href="basket.html">Basket</a>
</nav>
<div class="container">
<div class="filter-bar">
<input type="text" id="search-input" placeholder="Search products...">
<select id="category-filter">
<option value="all">All Categories</option>
</select>
</div>
<h2>All Products</h2>
<div class="product-grid" id="all-products"></div>
</div>
<br>
<footer>
<!--Change this to your company (You have to change this one every page)-->
<p>© 2025 Cheese Factory. All rights reserved.</p>
<p>Made with love in the UK | <a href="contact.html">Contact Us</a></p>
<div class="social-links">
<!--Add your link were the _blank (/@bob for tiktok) -->
<a href="https://facebook.com" target="_blank" aria-label="Facebook"><i class="fab fa-facebook"></i></a>
<a href="https://instagram.com" target="_blank" aria-label="Instagram"><i class="fab fa-instagram"></i></a>
<a href="https://x.com" target="_blank" aria-label="Twitter"><i class="fab fa-twitter"></i></a>
<a href="https://tiktok.com" target="_blank" aria-label="TikTok"><i class="fab fa-tiktok"></i></a>
</div>
</footer>
<script src="script.js"></script>
<script src="shop.js"></script>
<script>
const allContainer = document.getElementById('all-products');
const searchInput = document.getElementById('search-input');
const categorySelect = document.getElementById('category-filter');
loadProducts(allContainer, { featuredOnly: false });
let allProducts = [];
async function init() {
const url = 'products.json';
const response = await fetch(url);
allProducts = await response.json();
const categories = [...new Set(allProducts.map(p => p.category))];
categories.forEach(cat => {
const option = document.createElement('option');
option.value = cat;
option.textContent = cat;
categorySelect.appendChild(option);
});
applyFilters();
}
function applyFilters() {
const searchTerm = searchInput.value.toLowerCase();
const selectedCategory = categorySelect.value;
const filtered = allProducts.filter(product => {
const matchesSearch =
product.name.toLowerCase().includes(searchTerm) ||
product.description.toLowerCase().includes(searchTerm); // <-- added
const matchesCategory = selectedCategory === "all" || product.category === selectedCategory;
return matchesSearch && matchesCategory;
});
loadProducts(allContainer, { featuredOnly: false, overrideProducts: filtered });
}
searchInput.addEventListener('input', applyFilters);
categorySelect.addEventListener('change', applyFilters);
init();
</script>
</body>
</html>