Skip to content

Commit

Permalink
Merge pull request #55 from diogofranciscop/development
Browse files Browse the repository at this point in the history
Update jquery
  • Loading branch information
diogofranciscop authored Jan 8, 2025
2 parents f210028 + 0a4d293 commit b70e5f2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 63 deletions.
6 changes: 3 additions & 3 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<link rel="preload" href="/assets/js/version.js" as="script">

<!-- Scripts -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" defer></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="/assets/js/beacon.min.js?v=1.0" defer></script>
<script src="https://www.googletagmanager.com/gtag/js?id=G-896CVHSCS7" defer></script>
<script defer>
Expand Down Expand Up @@ -124,7 +124,7 @@
});
</script>

<script>
<script defer>
$(document).ready(function () {
// Extract serving details from page.serve
const servingText = {{ page.serve | jsonify }}; // Example: "4 pratos de sopa"
Expand Down Expand Up @@ -171,7 +171,7 @@
});

</script>
<script>
<script defer>
$(document).ready(function () {
// Extract serving details from page.serve
const servingText = {{ page.serve | jsonify }}; // Example: "4 pratos de sopa"
Expand Down
97 changes: 38 additions & 59 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
</div>
<!-- HTML !-->
<div class="filter-buttons">
<button class="button-3 filter-button button-5" data-role="filtros" aria-label="Filtros"><i class="fas fa-sliders-h"></i> FILTROS</button>
<button class="button-3 filter-button button-5" data-role="filtros" aria-label="Filtros"><i
class="fas fa-sliders-h"></i> FILTROS</button>
<button class="button-3 button-4" data-role="Almoço/Jantar" aria-label="Almoço/Jantar">ALMOÇO/JANTAR</button>
<button class="button-3 button-4" data-role="Pequeno-Almoço" aria-label="Pequeno-Almoço">PEQUENO-ALMOÇO</button>
<button class="button-3 button-4" data-role="Entrada" aria-label="Entrada">ENTRADAS</button>
Expand Down Expand Up @@ -83,34 +84,12 @@
</div>

<div class="posts" id="post-container">
{% assign first_page_count = 20 %}
{% for post in site.posts limit: first_page_count %}
<a href="{{ post.url }}" class="card" data-index="{{ forloop.index }}">
<div class="skeleton skeleton-card"></div>
{% if post.new == "yes" %}
<div class="new-tape">Nova Receita</div>
{% endif %}
<div class="card__overlay">
<p>{{ post.description }}</p>
</div>
<div class="card__img-container">
<!-- Optionally handle initial lazy-loading logic as you wish -->
<picture>
<source srcset="{{ post.image | replace: '.webp', '-126px.webp' }}" media="(max-width: 768px)" width="126" height="140">
<source srcset="{{ post.image | replace: '.webp', '-180px.webp' }}" media="(max-width: 1500px)"width="180" height="200">
<img src="{{ post.image }}" class="card__img" alt="{{ post.title }}" loading="auto">
</picture>
</div>
<div class="card__footer">
<span class="title-card">{{ post.title | upcase }}</span>
</div>
</a>
{% endfor %}

</div>
</div>
<div id="pagination-container" class="pagination"></div>
<script>
const filtrosButton = document.querySelector('.filter-button[data-role="filtros"]');
const filtrosButton = document.querySelector('.filter-button[data-role="filtros"]');
const filterBox = document.getElementById('filterBox');

// Add event listener to toggle 'hidden' class on filterBox when the button is clicked
Expand All @@ -121,35 +100,35 @@
<script>

const allPosts = [];
{% for post in site.posts %}
allPosts.push({
url: "{{ post.url }}",
title: "{{ post.title | escape }}",
description: "{{ post.description | escape }}",
image: "{{ post.image }}",
type: "{{ post.type | join: ',' }}",
time: "{{ post.time-total | join: ',' }}",
diet: "{{ post.diet | join: ',' }}",
new: "{{post.new }}"
});
{% endfor %}
{% for post in site.posts %}
allPosts.push({
url: "{{ post.url }}",
title: "{{ post.title | escape }}",
description: "{{ post.description | escape }}",
image: "{{ post.image }}",
type: "{{ post.type | join: ',' }}",
time: "{{ post.time-total | join: ',' }}",
diet: "{{ post.diet | join: ',' }}",
new: "{{post.new }}"
});
{% endfor %}
</script>

<script>$(document).ready(function () {
// Populate allPosts from the existing DOM
$('#post-container .card').each(function () {
// Populate allPosts from the existing DOM
$('#post-container .card').each(function () {
allPosts.push({
url: $(this).attr('href'),
title: $(this).find('.title-card').text(),
description: $(this).find('.card__overlay p').text(),
image: $(this).find('.card__img').attr('src'),
type: $(this).data('type'),
time: $(this).data('time'),
diet: $(this).data('diet'),
new: $(this).find('.new-tape').length > 0 ? "yes" : "no"
url: $(this).attr('href'),
title: $(this).find('.title-card').text(),
description: $(this).find('.card__overlay p').text(),
image: $(this).find('.card__img').attr('src'),
type: $(this).data('type'),
time: $(this).data('time'),
diet: $(this).data('diet'),
new: $(this).find('.new-tape').length > 0 ? "yes" : "no"
});
});
});
});
</script>
<script>
function adjustLazyLoading() {
Expand Down Expand Up @@ -190,21 +169,21 @@
<script>
// Function to adjust the number of visible posts based on screen size
function adjustStaticPosts() {
const isMobile = window.innerWidth <= 768;
const posts = document.querySelectorAll('#post-container .card');

posts.forEach((post, index) => {
if (isMobile && index >= 10) {
post.style.display = 'none'; // Hide posts after the 10th on mobile
} else {
post.style.display = 'block'; // Show all posts on larger screens
}
});
const isMobile = window.innerWidth <= 768;
const posts = document.querySelectorAll('#post-container .card');

posts.forEach((post, index) => {
if (isMobile && index >= 10) {
post.style.display = 'none'; // Hide posts after the 10th on mobile
} else {
post.style.display = 'block'; // Show all posts on larger screens
}
});
}

// Run on initial load
adjustStaticPosts();

// Re-run on window resize
window.addEventListener('resize', adjustStaticPosts);
</script>
</script>
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.0.78"
"version": "1.0.79"
}

0 comments on commit b70e5f2

Please sign in to comment.