Skip to content

Commit 6242bf7

Browse files
committed
feat: hide empty blog section
1 parent 32aac23 commit 6242bf7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

assets/js/site.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
[
134134
['comunidade', text('community')], ['conheca-tambem', text('partners')], ['membros', text('members')],
135135
['eventos', text('events')], ['projetos', text('projects')], ['blog', text('blog')], ['conduta', text('conduct')]
136-
].forEach(([id, label]) => nav.append(element('a', { href: `#${id}`, text: label, 'data-section': id })));
136+
].filter(([id]) => id !== 'blog' || state.posts.length)
137+
.forEach(([id, label]) => nav.append(element('a', { href: `#${id}`, text: label, 'data-section': id })));
137138
}
138139

139140
function renderHome(upcoming) {
@@ -268,12 +269,11 @@
268269
}
269270

270271
function renderPosts() {
272+
const section = byId('blog');
271273
const container = byId('post-list');
272274
clear(container);
275+
section.hidden = !state.posts.length;
273276
if (!state.posts.length) {
274-
const panel = element('div', { class: 'empty-panel' });
275-
panel.append(element('p', { text: text('noPosts') }), element('code', { text: 'data/posts.json' }));
276-
container.append(panel);
277277
return;
278278
}
279279
state.posts.forEach((post) => {
@@ -317,7 +317,7 @@
317317
if (!visible) return;
318318
document.querySelectorAll('.main-nav a').forEach((link) => link.classList.toggle('active', link.dataset.section === visible.target.id));
319319
}, { rootMargin: '-82px 0px -60% 0px' });
320-
SECTIONS.forEach((id) => observer.observe(byId(id)));
320+
SECTIONS.map(byId).filter((section) => !section.hidden).forEach((section) => observer.observe(section));
321321
}
322322

323323
async function load() {

0 commit comments

Comments
 (0)