|
133 | 133 | [ |
134 | 134 | ['comunidade', text('community')], ['conheca-tambem', text('partners')], ['membros', text('members')], |
135 | 135 | ['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 }))); |
137 | 138 | } |
138 | 139 |
|
139 | 140 | function renderHome(upcoming) { |
|
268 | 269 | } |
269 | 270 |
|
270 | 271 | function renderPosts() { |
| 272 | + const section = byId('blog'); |
271 | 273 | const container = byId('post-list'); |
272 | 274 | clear(container); |
| 275 | + section.hidden = !state.posts.length; |
273 | 276 | 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); |
277 | 277 | return; |
278 | 278 | } |
279 | 279 | state.posts.forEach((post) => { |
|
317 | 317 | if (!visible) return; |
318 | 318 | document.querySelectorAll('.main-nav a').forEach((link) => link.classList.toggle('active', link.dataset.section === visible.target.id)); |
319 | 319 | }, { 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)); |
321 | 321 | } |
322 | 322 |
|
323 | 323 | async function load() { |
|
0 commit comments