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 categories from "./categories";
|
||||||
import copy from "./copy";
|
import copy from "./copy";
|
||||||
import css from "./css";
|
import css from "./css";
|
||||||
|
@ -9,6 +10,7 @@ import tutorials from "./tutorials";
|
||||||
import years from "./years";
|
import years from "./years";
|
||||||
|
|
||||||
export = {
|
export = {
|
||||||
|
archive,
|
||||||
categories,
|
categories,
|
||||||
copy,
|
copy,
|
||||||
css,
|
css,
|
||||||
|
|
|
@ -23,6 +23,7 @@ async function generate(): Promise<Page[]> {
|
||||||
generators.years(posts);
|
generators.years(posts);
|
||||||
generators.rss.posts(posts)
|
generators.rss.posts(posts)
|
||||||
generators.categories(posts).then(generators.rss.categories);
|
generators.categories(posts).then(generators.rss.categories);
|
||||||
|
generators.archive(posts);
|
||||||
|
|
||||||
return 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>
|
</div>
|
||||||
<nav class="site-nav" role="navigation">
|
<nav class="site-nav" role="navigation">
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><%- fancyLink("Archive", "/archive/") %></li>
|
||||||
<li><%- fancyLink("Tutorials", "/tutorials/") %></li>
|
<li><%- fancyLink("Tutorials", "/tutorials/") %></li>
|
||||||
<li><%- fancyLink("RTFM", "https://rtfm.shadowfacts.net") %></li>
|
<li><%- fancyLink("RTFM", "https://rtfm.shadowfacts.net") %></li>
|
||||||
<li><%- fancyLink("Type", "https://type.shadowfacts.net") %></li>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="dropdown-link" aria-haspopup="true">Other <span class="arrow arrow-down" aria-hidden="true"></span></a>
|
<a href="#" class="dropdown-link" aria-haspopup="true">Other <span class="arrow arrow-down" aria-hidden="true"></span></a>
|
||||||
<ul aria-label="other links">
|
<ul aria-label="other links">
|
||||||
<li><%- fancyLink("Gitea", "https://git.shadowfacts.net") %></li>
|
<li><%- fancyLink("Gitea", "https://git.shadowfacts.net") %></li>
|
||||||
<li><%- fancyLink("Maven", "https://maven.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>
|
<li><%- fancyLink("Meme Machine", "https://mememachine.shadowfacts.net") %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue