Skip to content

Commit 210b42b

Browse files
authored
Add /news/ section (#437)
This adds a **News** section to the website. - Each news post lives in `/news/yyyy-mm-dd-slug/` in an `index.md` file and all local resources like images in the same folder. ![Screenshot 2025-03-18 at 19 27 36](https://github.com/user-attachments/assets/5d85133b-3051-4968-8a2d-f02b5b21639a) - I didn't manage to make the slug work in the `/news/` landing page. I think somehow Jekyll doesn't actually recognize my collection. As a current workaround, the raw path works. Someone more familiar with Jekyll internals may know how to fix this. ![Screenshot 2025-03-18 at 19 28 11](https://github.com/user-attachments/assets/45b6c962-8add-416e-b795-a367aa3c12b4) @lukewagner and @rossberg, does this approach work for your (time-critical) needs?
1 parent c808ab2 commit 210b42b

File tree

7 files changed

+50
-1
lines changed

7 files changed

+50
-1
lines changed

_config.yml

+10
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ destination: docs
3333

3434
permalink: pretty
3535

36+
collections:
37+
news:
38+
output: true
39+
permalink: /news/:path/
40+
3641
defaults:
42+
- scope:
43+
path: 'news'
44+
type: 'news'
45+
values:
46+
layout: 'news'
3747
- scope:
3848
path: 'design'
3949
values:

_includes/header.html

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<a class="site-nav-item btn" href="/community/resources/"
3939
>Community</a
4040
>
41+
<a class="site-nav-item btn" href="/news/"
42+
>News</a
43+
>
4144
</nav>
4245
</div>
4346
</header>

_layouts/news.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% include header.html %}
2+
<section>
3+
<div class="container">
4+
{{content}}
5+
</div>
6+
</section>
7+
{% include footer.html %}

css/custom.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ nav a:hover {
298298
clear: both;
299299
}
300300

301+
.container img,
302+
.container video {
303+
max-width: 100%;
304+
height: auto;
305+
}
306+
301307
@media (min-width: 544px) {
302308
.container {
303309
/* max-width:576px; */
@@ -340,7 +346,7 @@ nav a:hover {
340346
margin-right: auto;
341347
padding-left: 15px;
342348
padding-right: 15px;
343-
max-width: 800px;
349+
max-width: 900px;
344350
}
345351

346352
.container-narrow::after {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Big News!"
3+
date: 2025-03-19
4+
layout: news
5+
---
6+
7+
We launched something new 🎉! A [News](/news/) section for the WebAssembly homepage!
8+
9+
![Two cups with the WebAssembly logo](wasm-cups.png)
341 KB
Loading

news/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: news
3+
title: News
4+
---
5+
<h1>News</h1>
6+
<ul>
7+
{% for page in site.pages %}
8+
{% if page.path contains 'news/20' %}
9+
<li>
10+
<a href="{{ page.url }}">{{ page.url }}</a>
11+
</li>
12+
{% endif %}
13+
{% endfor %}
14+
</ul>

0 commit comments

Comments
 (0)