diff --git a/lib/generate/categories.ts b/lib/generate/categories.ts deleted file mode 100644 index 60f953c..0000000 --- a/lib/generate/categories.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Page, PostMetadata } from "../metadata"; -import generatePaginated from "./paginated"; - -export default async function(posts: Page[]): Promise> { - const categories = new Map(); - - for (const post of posts) { - const category = (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; -} \ No newline at end of file diff --git a/lib/generate/index.ts b/lib/generate/index.ts index 20b1ca5..0b45c0f 100644 --- a/lib/generate/index.ts +++ b/lib/generate/index.ts @@ -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, }; diff --git a/lib/generate/rss.ts b/lib/generate/rss.ts index 7523e2a..8ea4d3d 100644 --- a/lib/generate/rss.ts +++ b/lib/generate/rss.ts @@ -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 = (a.metadata).date; const bDate = (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) { - categories.forEach((posts, category) => { - generateFeed(posts, `/${category}/`, category); +export async function tags(tags: Map) { + tags.forEach((posts, tag) => { + generateFeed(posts, `/${tag}/`, tag); }); } diff --git a/lib/generate/tags.ts b/lib/generate/tags.ts new file mode 100644 index 0000000..67d5928 --- /dev/null +++ b/lib/generate/tags.ts @@ -0,0 +1,26 @@ +import { Page, PostMetadata } from "../metadata"; +import generatePaginated from "./paginated"; + +export default async function(posts: Page[]): Promise> { + const taggedPosts = new Map(); + + for (const post of posts) { + const tags = (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; +} diff --git a/lib/index.ts b/lib/index.ts index 614cae7..d468fdb 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -22,7 +22,7 @@ async function generate(): Promise { 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; diff --git a/lib/metadata.ts b/lib/metadata.ts index 4dc7050..666908e 100644 --- a/lib/metadata.ts +++ b/lib/metadata.ts @@ -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; diff --git a/site/feed.xml.ejs b/site/feed.xml.ejs index 3bfd9de..4937b32 100644 --- a/site/feed.xml.ejs +++ b/site/feed.xml.ejs @@ -1,13 +1,16 @@ - Shadowfacts<% if (category) { %> (<%= category %>)<% } %> + Shadowfacts<% if (tag) { %> (<%= tag %>)<% } %> - <% if (category) { %> - Only <%= category %> posts. + <% if (tag) { %> + Only <%= tag %> posts. <% } else { %> Just my various ramblings. <% } %> + <% if (tag) { %> + + <% } %> https://shadowfacts.net<%= feedPath %> @@ -21,12 +24,14 @@ <%= post.metadata.title %> <%= post.metadata.date.toISOString() %> - <% if (post.metadata.category) { %> - + <% if (post.metadata.tags) { %> + <% for (const tag of post.metadata.tags) { %> + + <% } %> <% } %> ]]> <% } %> - \ No newline at end of file + diff --git a/site/includes/article-meta.html.ejs b/site/includes/article-meta.html.ejs index 5bca74b..5006b1f 100644 --- a/site/includes/article-meta.html.ejs +++ b/site/includes/article-meta.html.ejs @@ -8,9 +8,11 @@ <% const fullFormatted = formatDate(metadata.date, "hh:mm:ss A MMM Do, YYYY") %> - <% if (metadata.category) { %> + <% if (metadata.tags) { %> in - <%= metadata.category %> + <% for (let i = 0; i < metadata.tags.length; i++) { %> + <%= i < metadata.tags.length - 1 ? ", " : "" %> + <% } %> <% } else if (metadata.series) { %> in <%= metadata.seriesName %> diff --git a/site/posts/2016-05-05-hello-world.md b/site/posts/2016-05-05-hello-world.md index 4fd80e6..d67cc81 100644 --- a/site/posts/2016-05-05-hello-world.md +++ b/site/posts/2016-05-05-hello-world.md @@ -1,9 +1,9 @@ ``` 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." ``` -Hello again, world! Welcome to the third iteration of my website. Originally my site was hosted on GitHub pages and only available at [shadowfacts.github.io](https://shadowfacts.github.io). I wrote a couple of tutorials on using [Forge](http://minecraftforge.net) to mod 1.6.4, but never really finished anything other than super basic setup/recipes. Later, after I got [shadowfacts.net](https://shadowfacts.net), I decided to set up a propper website using [WordPress](https://wordpress.org). I copied over all of the old tutorials from my old GitHub pages site, but never really did anything else with it. After my website being offline for almost a year, I've finally decided to switch back to GitHub for the simplicity (also I <3 [Jekyll](https://jekyllrb.com)). Using Jekyll, I've got a structure in place that I can use to easily publish tutorials in a structured format. There is one tutorial series that I'm currently writing and that is [Forge Mods in 1.9](/tutorials/forge-modding-19/), and hopefully more series will follow. \ No newline at end of file +Hello again, world! Welcome to the third iteration of my website. Originally my site was hosted on GitHub pages and only available at [shadowfacts.github.io](https://shadowfacts.github.io). I wrote a couple of tutorials on using [Forge](http://minecraftforge.net) to mod 1.6.4, but never really finished anything other than super basic setup/recipes. Later, after I got [shadowfacts.net](https://shadowfacts.net), I decided to set up a propper website using [WordPress](https://wordpress.org). I copied over all of the old tutorials from my old GitHub pages site, but never really did anything else with it. After my website being offline for almost a year, I've finally decided to switch back to GitHub for the simplicity (also I <3 [Jekyll](https://jekyllrb.com)). Using Jekyll, I've got a structure in place that I can use to easily publish tutorials in a structured format. There is one tutorial series that I'm currently writing and that is [Forge Mods in 1.9](/tutorials/forge-modding-19/), and hopefully more series will follow. diff --git a/site/posts/2016-05-21-194-porting-spree.md b/site/posts/2016-05-21-194-porting-spree.md index 3ed481a..be8d8c7 100644 --- a/site/posts/2016-05-21-194-porting-spree.md +++ b/site/posts/2016-05-21-194-porting-spree.md @@ -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)." @@ -42,4 +42,4 @@ Now that Forge for 1.9.4 is [out](http://files.minecraftforge.net/maven/net/mine

ShadowTweaks

1.9.0

A little tweaks mod with a variety of client/server tweaks.

- \ No newline at end of file + diff --git a/site/posts/2016-06-29-introducing-rtfm.md b/site/posts/2016-06-29-introducing-rtfm.md index bbae28b..61ee8c9 100644 --- a/site/posts/2016-06-29-introducing-rtfm.md +++ b/site/posts/2016-06-29-introducing-rtfm.md @@ -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." @@ -10,4 +10,4 @@ metadata.shortDesc = "RTFM is the brand new website that will contain the docume -![XKCD #293 RTFM](https://imgs.xkcd.com/comics/rtfm.png) \ No newline at end of file +![XKCD #293 RTFM](https://imgs.xkcd.com/comics/rtfm.png) diff --git a/site/posts/2016-06-30-forge-1102-tutorials.md b/site/posts/2016-06-30-forge-1102-tutorials.md index d89e3cf..76bff62 100644 --- a/site/posts/2016-06-30-forge-1102-tutorials.md +++ b/site/posts/2016-06-30-forge-1102-tutorials.md @@ -1,9 +1,9 @@ ``` 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." ``` -The Forge modding tutorials have all the been [updated to MC 1.10.2](/tutorials/forge-modding-1102/) as has the [GitHub repo](https://github.com/shadowfacts/TutorialMod/). \ No newline at end of file +The Forge modding tutorials have all the been [updated to MC 1.10.2](/tutorials/forge-modding-1102/) as has the [GitHub repo](https://github.com/shadowfacts/TutorialMod/). diff --git a/site/posts/2016-07-28-introducing-mirror.md b/site/posts/2016-07-28-introducing-mirror.md index b4cd814..00fee2b 100644 --- a/site/posts/2016-07-28-introducing-mirror.md +++ b/site/posts/2016-07-28-introducing-mirror.md @@ -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." @@ -148,4 +148,4 @@ Mirror.ofAllUnwrapped(Test.class, Test2.class) // create the stream of classes [enum]: https://shadowfacts.net/Mirror/net/shadowfacts/mirror/MirrorEnum.html [constructor]: https://shadowfacts.net/Mirror/net/shadowfacts/mirror/MirrorConstructor.html [method]: https://shadowfacts.net/Mirror/net/shadowfacts/mirror/MirrorMethod.html -[field]: https://shadowfacts.net/Mirror/net/shadowfacts/mirror/MirrorField.html \ No newline at end of file +[field]: https://shadowfacts.net/Mirror/net/shadowfacts/mirror/MirrorField.html diff --git a/site/posts/2016-08-06-kotlin-and-forge.md b/site/posts/2016-08-06-kotlin-and-forge.md index 31470fe..a135b0e 100644 --- a/site/posts/2016-08-06-kotlin-and-forge.md +++ b/site/posts/2016-08-06-kotlin-and-forge.md @@ -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. " diff --git a/site/posts/2016-08-07-the-great-redesign.md b/site/posts/2016-08-07-the-great-redesign.md index aadaf6e..98e26e2 100644 --- a/site/posts/2016-08-07-the-great-redesign.md +++ b/site/posts/2016-08-07-the-great-redesign.md @@ -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." diff --git a/site/posts/2016-10-02-type.md b/site/posts/2016-10-02-type.md index d35cdce..3e4b86f 100644 --- a/site/posts/2016-10-02-type.md +++ b/site/posts/2016-10-02-type.md @@ -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." diff --git a/site/posts/2017-02-13-the-pretty-good-minor-update.md b/site/posts/2017-02-13-the-pretty-good-minor-update.md index 579a6dd..f163375 100644 --- a/site/posts/2017-02-13-the-pretty-good-minor-update.md +++ b/site/posts/2017-02-13-the-pretty-good-minor-update.md @@ -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." @@ -18,4 +18,4 @@ After reading this [blog post](http://jacquesmattheij.com/the-fastest-blog-in-th -Additionally, there's now a fallback `