forked from shadowfacts/shadowfacts.net
Add Archive page
This commit is contained in:
parent
04c43fa483
commit
afb844db87
|
@ -0,0 +1,13 @@
|
|||
import * as metadata from "../metadata";
|
||||
import { Page } from "../metadata";
|
||||
import * as util from "../util";
|
||||
import layout from "../layout";
|
||||
|
||||
export default async function archive(posts: Page[]) {
|
||||
const page = await metadata.get("site/archive.html.ejs");
|
||||
page.text = util.render(page.text, {
|
||||
posts,
|
||||
}, "site/archive.html.ejs");
|
||||
page.text = await layout(page.text, page.metadata, page.metadata.layout!);
|
||||
util.write("archive/index.html", page.text);
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
import archive from "./archive";
|
||||
import categories from "./categories";
|
||||
import copy from "./copy";
|
||||
import css from "./css";
|
||||
|
@ -9,6 +10,7 @@ import tutorials from "./tutorials";
|
|||
import years from "./years";
|
||||
|
||||
export = {
|
||||
archive,
|
||||
categories,
|
||||
copy,
|
||||
css,
|
||||
|
|
|
@ -23,6 +23,7 @@ async function generate(): Promise<Page[]> {
|
|||
generators.years(posts);
|
||||
generators.rss.posts(posts)
|
||||
generators.categories(posts).then(generators.rss.categories);
|
||||
generators.archive(posts);
|
||||
|
||||
return posts;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
```
|
||||
metadata.layout = "default.html.ejs"
|
||||
metadata.title = "Archive"
|
||||
```
|
||||
|
||||
<div class="main">
|
||||
<% let currentYear %>
|
||||
<% for (const post of posts) { %>
|
||||
<% if (post.metadata.date.getFullYear() !== currentYear) { %>
|
||||
<% if (currentYear) { %>
|
||||
</ul>
|
||||
<% } %>
|
||||
<% currentYear = post.metadata.date.getFullYear() %>
|
||||
<h2><%= currentYear %></h2>
|
||||
<ul>
|
||||
<% } %>
|
||||
<li>
|
||||
<a href="<%= post.metadata.permalink %>">
|
||||
<%= post.metadata.title %>
|
||||
</a>
|
||||
</li>
|
||||
<% } %>
|
||||
</div>
|
|
@ -48,14 +48,15 @@
|
|||
</div>
|
||||
<nav class="site-nav" role="navigation">
|
||||
<ul>
|
||||
<li><%- fancyLink("Archive", "/archive/") %></li>
|
||||
<li><%- fancyLink("Tutorials", "/tutorials/") %></li>
|
||||
<li><%- fancyLink("RTFM", "https://rtfm.shadowfacts.net") %></li>
|
||||
<li><%- fancyLink("Type", "https://type.shadowfacts.net") %></li>
|
||||
<li>
|
||||
<a href="#" class="dropdown-link" aria-haspopup="true">Other <span class="arrow arrow-down" aria-hidden="true"></span></a>
|
||||
<ul aria-label="other links">
|
||||
<li><%- fancyLink("Gitea", "https://git.shadowfacts.net") %></li>
|
||||
<li><%- fancyLink("Maven", "https://maven.shadowfacts.net") %></li>
|
||||
<li><%- fancyLink("Type", "https://type.shadowfacts.net") %></li>
|
||||
<li><%- fancyLink("Meme Machine", "https://mememachine.shadowfacts.net") %></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue