Replace categories with tags
This commit is contained in:
parent
3fbd07aef9
commit
ada0463e75
|
@ -1,24 +0,0 @@
|
|||
import { Page, PostMetadata } from "../metadata";
|
||||
import generatePaginated from "./paginated";
|
||||
|
||||
export default async function(posts: Page[]): Promise<Map<string, Page[]>> {
|
||||
const categories = new Map<string, Page[]>();
|
||||
|
||||
for (const post of posts) {
|
||||
const category = (<PostMetadata>post.metadata).category;
|
||||
if (!categories.has(category)) {
|
||||
categories.set(category, []);
|
||||
}
|
||||
categories.get(category)!.push(post);
|
||||
}
|
||||
|
||||
categories.forEach((categoryPosts, category) => {
|
||||
generatePaginated(categoryPosts, `/${category}/`, "site/category.html.ejs", {
|
||||
category
|
||||
}, {
|
||||
title: `${category} posts`
|
||||
});
|
||||
});
|
||||
|
||||
return categories;
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
import archive from "./archive";
|
||||
import categories from "./categories";
|
||||
import copy from "./copy";
|
||||
import css from "./css";
|
||||
import errors from "./errors";
|
||||
import homepage from "./homepage";
|
||||
import posts from "./posts";
|
||||
import * as rss from "./rss";
|
||||
import tags from "./tags";
|
||||
import tutorials from "./tutorials";
|
||||
import years from "./years";
|
||||
|
||||
export = {
|
||||
archive,
|
||||
categories,
|
||||
copy,
|
||||
css,
|
||||
errors,
|
||||
homepage,
|
||||
posts,
|
||||
rss,
|
||||
tags,
|
||||
tutorials,
|
||||
years,
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Page, PostMetadata } from "../metadata";
|
|||
import * as util from "../util";
|
||||
import { TutorialSeries } from "./tutorials";
|
||||
|
||||
async function generateFeed(posts: Page[], permalink: string, category?: string) {
|
||||
async function generateFeed(posts: Page[], permalink: string, tag?: string) {
|
||||
posts = posts.sort((a, b) => {
|
||||
const aDate = <Date>(<PostMetadata>a.metadata).date;
|
||||
const bDate = <Date>(<PostMetadata>b.metadata).date;
|
||||
|
@ -16,7 +16,7 @@ async function generateFeed(posts: Page[], permalink: string, category?: string)
|
|||
let text = (await fs.readFile("site/feed.xml.ejs")).toString();
|
||||
text = util.render(text, {
|
||||
posts,
|
||||
category,
|
||||
tag,
|
||||
permalink,
|
||||
feedPath: dest
|
||||
}, "site/feed.xml.ejs");
|
||||
|
@ -28,9 +28,9 @@ export async function posts(posts: Page[]) {
|
|||
generateFeed(posts, "/");
|
||||
}
|
||||
|
||||
export async function categories(categories: Map<string, Page[]>) {
|
||||
categories.forEach((posts, category) => {
|
||||
generateFeed(posts, `/${category}/`, category);
|
||||
export async function tags(tags: Map<string, Page[]>) {
|
||||
tags.forEach((posts, tag) => {
|
||||
generateFeed(posts, `/${tag}/`, tag);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import { Page, PostMetadata } from "../metadata";
|
||||
import generatePaginated from "./paginated";
|
||||
|
||||
export default async function(posts: Page[]): Promise<Map<string, Page[]>> {
|
||||
const taggedPosts = new Map<string, Page[]>();
|
||||
|
||||
for (const post of posts) {
|
||||
const tags = (<PostMetadata>post.metadata).tags;
|
||||
for (const tag of tags) {
|
||||
if (!taggedPosts.has(tag)) {
|
||||
taggedPosts.set(tag, []);
|
||||
}
|
||||
taggedPosts.get(tag)!.push(post);
|
||||
}
|
||||
}
|
||||
|
||||
taggedPosts.forEach((tagPosts, tag) => {
|
||||
generatePaginated(tagPosts, `/${tag}/`, "site/tag.html.ejs", {
|
||||
tag
|
||||
}, {
|
||||
title: `${tag} posts`
|
||||
});
|
||||
});
|
||||
|
||||
return taggedPosts;
|
||||
}
|
|
@ -22,7 +22,7 @@ async function generate(): Promise<Page[]> {
|
|||
generators.homepage(posts);
|
||||
generators.years(posts);
|
||||
generators.rss.posts(posts)
|
||||
generators.categories(posts).then(generators.rss.categories);
|
||||
generators.tags(posts).then(generators.rss.tags);
|
||||
generators.archive(posts);
|
||||
|
||||
return posts;
|
||||
|
|
|
@ -16,7 +16,7 @@ export interface Metadata {
|
|||
export interface PostMetadata extends Metadata {
|
||||
title: string;
|
||||
slug: string;
|
||||
category: string;
|
||||
tags: string[];
|
||||
date: string | Date;
|
||||
readingTime?: number;
|
||||
wordCount?: number;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<title>Shadowfacts<% if (category) { %> (<%= category %>)<% } %></title>
|
||||
<title>Shadowfacts<% if (tag) { %> (<%= tag %>)<% } %></title>
|
||||
<subtitle>
|
||||
<% if (category) { %>
|
||||
Only <%= category %> posts.
|
||||
<% if (tag) { %>
|
||||
Only <%= tag %> posts.
|
||||
<% } else { %>
|
||||
Just my various ramblings.
|
||||
<% } %>
|
||||
</subtitle>
|
||||
<% if (tag) { %>
|
||||
<category term="<%= tag %>" />
|
||||
<% } %>
|
||||
<link rel="alternate" type="text/html" href="https://shadowfacts.net<%= permalink %>" />
|
||||
<link rel="self" href="https://shadowfacts.net<%= feedPath %>" type="application/atom+xml" />
|
||||
<id>https://shadowfacts.net<%= feedPath %></id>
|
||||
|
@ -21,8 +24,10 @@
|
|||
<title><%= post.metadata.title %></title>
|
||||
<updated><%= post.metadata.date.toISOString() %></updated>
|
||||
<link rel="alternate" type="text/html" href="https://shadowfacts.net<%= post.metadata.permalink %>" />
|
||||
<% if (post.metadata.category) { %>
|
||||
<category term="<%= post.metadata.category %>" />
|
||||
<% if (post.metadata.tags) { %>
|
||||
<% for (const tag of post.metadata.tags) { %>
|
||||
<category term="<%= tag %>" />
|
||||
<% } %>
|
||||
<% } %>
|
||||
<content type="html"><![CDATA[
|
||||
<%- post.text %>
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
<% const fullFormatted = formatDate(metadata.date, "hh:mm:ss A MMM Do, YYYY") %>
|
||||
<time itemprop="datePublished" datetime="<%= metadata.date.toISOString() %>" title="<%= fullFormatted %>"><%= formatted %></time>
|
||||
</span>
|
||||
<% if (metadata.category) { %>
|
||||
<% if (metadata.tags) { %>
|
||||
in
|
||||
<span itemprop="articleSection"><a href="/<%= metadata.category %>/" rel="category"><%= metadata.category %></a></span>
|
||||
<% for (let i = 0; i < metadata.tags.length; i++) { %>
|
||||
<span itemprop="articleSection"><a href="/<%= metadata.tags[i] %>/" rel="tag"><%= metadata.tags[i] %></a></span><%= i < metadata.tags.length - 1 ? ", " : "" %>
|
||||
<% } %>
|
||||
<% } else if (metadata.series) { %>
|
||||
in
|
||||
<span itemprop="articleSection"><a href="/tutorials/<%= metadata.series %>" rel="category"><%= metadata.seriesName %></a></span>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Hello, World!"
|
||||
metadata.category = "meta"
|
||||
metadata.tags = ["meta"]
|
||||
metadata.date = "2016-05-06 11:13:18 -0400"
|
||||
metadata.oldPermalink = ["/meta/2016/06/07/hello-world/", "/meta/2016/hello-world/"]
|
||||
metadata.shortDesc = "Hello again, world! Welcome to the third iteration of my website."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "1.9.4 Porting Spree"
|
||||
metadata.category = "minecraft"
|
||||
metadata.tags = ["minecraft"]
|
||||
metadata.date = "2016-05-21 17:47:18 -0400"
|
||||
metadata.oldPermalink = ["/mods/2016/05/21/194-porting-spree/", "/minecraft/2016/1-9-4-porting-spree/"]
|
||||
metadata.shortDesc = "Now that Forge for 1.9.4 is out, I've begun the log and arduous process of porting my mods to 1.9.4 (if by long and arduous, you mean short and trivial)."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Introducing RTFM"
|
||||
metadata.category = "minecraft"
|
||||
metadata.tags = ["minecraft"]
|
||||
metadata.date = "2016-06-29 12:00:00 -0400"
|
||||
metadata.oldPermalink = ["/meta/2016/06/29/introducing-rtfm/", "/minecraft/2016/introducing-rtfm/"]
|
||||
metadata.shortDesc = "RTFM is the brand new website that will contain the documentation for all of my projects, currently it only contains documentation for MC mods."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Forge Modding Tutorials for 1.10.2"
|
||||
metadata.category = "minecraft"
|
||||
metadata.tags = ["minecraft"]
|
||||
metadata.date = "2016-06-30 10:35:00 -0400"
|
||||
metadata.oldPermalink = ["/meta/2016/06/30/forge-1102-tutorials/", "/minecraft/2016/forge-modding-tutorials-for-1-10-2"]
|
||||
metadata.shortDesc = "The Forge modding tutorials have all the been updated to MC 1.10.2 as has the GitHub repo."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Introducing Mirror"
|
||||
metadata.category = "java"
|
||||
metadata.tags = ["java"]
|
||||
metadata.date = "2016-07-28 16:45:00 -0400"
|
||||
metadata.oldPermalink = ["/java/2016/07/28/introducing-mirror/", "/java/2016/introducing-mirror/"]
|
||||
metadata.shortDesc = "Allow me to introduce my latest project, Mirror. Mirror is a reflection library for Java designed to take advantage of the streams, lambdas, and optionals introduced in Java 8."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Kotlin and Minecraft Forge"
|
||||
metadata.category = "minecraft"
|
||||
metadata.tags = ["minecraft"]
|
||||
metadata.date = "2016-08-06 16:45:30 -0400"
|
||||
metadata.oldPermalink = ["/forge/2016/08/06/kotlin-and-forge/", "/minecraft/2016/kotlin-and-minecraft-forge/"]
|
||||
metadata.shortDesc = "So, you wanna use Kotlin in your Forge mod? Well there's good news, I've just released Forgelin, a fork of Emberwalker's Forgelin, a library that provides utilities for using Kotlin with Minecraft/Forge. "
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "The Great Redesign"
|
||||
metadata.category = "meta"
|
||||
metadata.tags = ["meta"]
|
||||
metadata.date = "2016-08-07 15:39:48 -0400"
|
||||
metadata.oldPermalink = ["/meta/2016/08/07/the-great-redesign/", "/meta/2016/the-great-redesign/"]
|
||||
metadata.shortDesc = "Welcome to the fourth iteration of my website."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Type: A FOSS clone of typing.io"
|
||||
metadata.category = "misc"
|
||||
metadata.tags = ["misc"]
|
||||
metadata.date = "2016-10-08 17:29:42 -0400"
|
||||
metadata.oldPermalink = ["/misc/2016/10/08/type/", "/misc/2016/type/"]
|
||||
metadata.shortDesc = "I made an awesome FOSS clone of typing.io that you can check out at type.shadowfacts.net."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "The Pretty Good Minor Update"
|
||||
metadata.category = "meta"
|
||||
metadata.tags = ["meta"]
|
||||
metadata.date = "2017-02-17 14:30:42 -0400"
|
||||
metadata.oldPermalink = ["/meta/2017/02/17/the-pretty-good-minor-update/", "/meta/2017/the-pretty-good-minor-update/"]
|
||||
metadata.shortDesc = "It's been about six months since the last time I redesigned the site, and while I didn't want to redesign it yet again, I felt it could use a little update to make sure everything's still good."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Comments Powered by GitHub"
|
||||
metadata.category = "meta"
|
||||
metadata.tags = ["meta"]
|
||||
metadata.date = "2017-04-23 09:05:42 -0400"
|
||||
metadata.oldPermalink = ["/meta/2017/04/23/comments-powered-by-github/", "/meta/2017/comments-powered-by-git-hub/"]
|
||||
metadata.shortDesc = "I built a way of commenting on my static website using GitHub to store comments."
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Reincarnation"
|
||||
metadata.category = "meta"
|
||||
metadata.tags = ["meta"]
|
||||
metadata.date = "2019-09-18 10:34:42 -0400"
|
||||
metadata.shortDesc = "Stand by for reincarnation."
|
||||
metadata.oldPermalink = "/meta/2019/reincarnation/"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "ActivityPub Resources"
|
||||
metadata.category = "activitypub"
|
||||
metadata.tags = ["activitypub"]
|
||||
metadata.date = "2019-09-22 17:50:42 -0400"
|
||||
metadata.shortDesc = "A compilation of resources I found useful in learning/implementing ActivityPub."
|
||||
metadata.oldPermalink = "/activitypub/2019/activity-pub-resources/"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Learning Elixir"
|
||||
metadata.category = "elixir"
|
||||
metadata.tags = ["elixir"]
|
||||
metadata.date = "2019-10-10 12:29:42 -0400"
|
||||
metadata.shortDesc = "How I learned Elixir and why I love it."
|
||||
metadata.oldPermalink = "/elixir/2019/learning-elixir/"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Building a JavaScript-Free Slide-Over Menu"
|
||||
metadata.category = "web"
|
||||
metadata.tags = ["web"]
|
||||
metadata.date = "2019-11-11 21:08:42 -0400"
|
||||
metadata.shortDesc = "Building a slide-over hamburger menu without using JavaScript."
|
||||
metadata.oldPermalink = "/web/2019/js-free-hamburger-menu/"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Mocking HTTP Requests for iOS App UI Tests"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift"]
|
||||
metadata.date = "2019-12-22 19:12:42 -0400"
|
||||
metadata.shortDesc = "Integrating a tiny web server into your Xcode UI test target to mock HTTP requests."
|
||||
metadata.oldPermalink = "/ios/2019/mock-http-ios-ui-testing/"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Faking the Mongo Eval Command"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift"]
|
||||
metadata.date = "2020-01-28 19:33:42 -0400"
|
||||
metadata.shortDesc = "MongoDB 4.2 removed the eval command, which is a good security measure, but unfortunate for building database-viewing GUI."
|
||||
metadata.slug = "faking-mongo-eval"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Simple Swift Promises"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift"]
|
||||
metadata.date = "2020-02-18 22:10:42 -0400"
|
||||
metadata.shortDesc = "Building a rudimentary implementation of asynchronous promises in Swift."
|
||||
metadata.slug = "simple-swift-promises"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Writing a JavaScript Syntax Highlighter in Swift"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift"]
|
||||
metadata.date = "2020-04-09 11:48:42 -0400"
|
||||
metadata.shortDesc = "Things I learned while building a tiny syntax highlighter."
|
||||
metadata.slug = "syntax-highlighting-javascript"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "The Sorry State of Thunderbolt 3 Docks"
|
||||
metadata.category = "computers"
|
||||
metadata.tags = ["computers"]
|
||||
metadata.date = "2020-04-13 17:19:42 -0400"
|
||||
metadata.shortDesc = "On a quest to find a Thunderbolt dock that meets my needs."
|
||||
metadata.slug = "thunderbolt-3"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Switching to Vim"
|
||||
metadata.category = "editors"
|
||||
metadata.tags = ["editors"]
|
||||
metadata.date = "2020-05-21 18:22:42 -0400"
|
||||
metadata.shortDesc = "How I went about joining the cult of Vim."
|
||||
```
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Algorithmic Bias"
|
||||
metadata.category = "misc"
|
||||
metadata.tags = ["misc"]
|
||||
metadata.date = "2020-06-05 09:55:42 -0400"
|
||||
metadata.shortDesc = ""
|
||||
```
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Replicating Safari's Link Preview Animation"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift"]
|
||||
metadata.date = "2020-07-03 16:28:42 -0400"
|
||||
metadata.shortDesc = ""
|
||||
metadata.slug = "uipreviewparameters-textlinerects"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "Implement a Gemini Protocol Client Using Network.framework"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift", "gemini"]
|
||||
metadata.date = "2020-07-22 21:57:42 -0400"
|
||||
metadata.shortDesc = ""
|
||||
metadata.slug = "gemini-network-framework"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
```
|
||||
metadata.title = "SwiftUI Auto-Expanding Text Views"
|
||||
metadata.category = "swift"
|
||||
metadata.tags = ["swift"]
|
||||
metadata.date = "2020-08-29 11:20:42 -0400"
|
||||
metadata.shortDesc = "Building a non-scrolling UITextView for use in SwiftUI layouts."
|
||||
metadata.slug = "swiftui-expanding-text-view"
|
||||
|
|
|
@ -3,9 +3,9 @@ metadata.layout = "default.html.ejs"
|
|||
```
|
||||
|
||||
<div class="main">
|
||||
<h1 class="page-heading"><%= category %> posts</h1>
|
||||
<h1 class="page-heading"><%= tag %> posts</h1>
|
||||
<p class="rss">
|
||||
Subscribe to just <%= category %> posts via <a href="/<%= category %>/feed.xml">RSS</a>.
|
||||
Subscribe to just <%= tag %> posts via <a href="/<%= tag %>/feed.xml">RSS</a>.
|
||||
</p>
|
||||
|
||||
<% for (const post of posts) { %>
|
Loading…
Reference in New Issue