summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_posts/processPosts.js30
-rw-r--r--posts.html5
-rw-r--r--posts/tag_[object Object].html36
-rw-r--r--posts/tag_personal.html36
4 files changed, 99 insertions, 8 deletions
diff --git a/_posts/processPosts.js b/_posts/processPosts.js
index 9db4103..55c97df 100644
--- a/_posts/processPosts.js
+++ b/_posts/processPosts.js
@@ -18,9 +18,22 @@ const posts = [
}
];
+function createTagFile(tag) {
+ const dir = path.resolve(path.join(__dirname, '..', 'posts'));
+
+ if (!fs.existsSync(dir)) {
+ fs.mkdirSync(dir);
+ }
+
+
+ const tagFileName = `tag_${tag.id}.html`
+ createPostPage(path.join(__dirname, '..', 'posts', tagFileName), tag.id)
+ return `/posts/${tagFileName}`;
+}
+
function createTag(tag) {
return `
- <button id="${tag.id}">${tag.title}</button>
+ <a href="${createTagFile(tag)}"><button id="${tag.id}">${tag.title}</button></a>
`;
}
@@ -77,7 +90,8 @@ function createPostLink(post) {
`;
}
-const output = `
+function createPostPage(outputFile, postFilter) {
+ const output = `
<!DOCTYPE html>
<html lang="en">
<head>
@@ -101,21 +115,25 @@ const output = `
</nav>
</header>
- <section>
+ ${postFilter ? '' : `<section>
<h2>Tags</h2>
+
<div id='tag_list'>
${tags.map(createTag)}
</div>
- </section
+ </section`}
<section>
<h2>Posts</h2>
<ul id='post_list'>
- ${posts.map(createPostLink)}
+ ${posts.filter(post => !postFilter || post.tags.includes(postFilter)).map(createPostLink)}
</ul>
</section>
</body>
</html>
`
-fs.writeFileSync(path.join(__dirname, '..', 'posts.html'), output);
+ fs.writeFileSync(outputFile, output);
+}
+
+createPostPage(path.join(__dirname, '..', 'posts.html'));
diff --git a/posts.html b/posts.html
index 777073c..3f75430 100644
--- a/posts.html
+++ b/posts.html
@@ -24,12 +24,13 @@
<section>
<h2>Tags</h2>
+
<div id='tag_list'>
- <button id="personal">Personal 👨</button>
+ <a href="/posts/tag_personal.html"><button id="personal">Personal 👨</button></a>
</div>
- </section
+ </section
<section>
<h2>Posts</h2>
diff --git a/posts/tag_[object Object].html b/posts/tag_[object Object].html
new file mode 100644
index 0000000..1999d78
--- /dev/null
+++ b/posts/tag_[object Object].html
@@ -0,0 +1,36 @@
+
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta charset="utf-8">
+ <link rel="stylesheet" href="/index.css">
+ <link rel="stylesheet" href="/posts.css">
+ <title>Matthew Kosarek</title>
+ <link rel="shortcut icon" href="/favicon/favicon.ico" type="image/x-icon">
+ </head>
+ <body>
+ <header>
+ <h1>Matthew Kosarek</h1>
+ <nav>
+ <ul>
+ <li><a href='/'>&#127969; Home</a></li>
+ <li><a href='/resume.html'>&#128216; CV</a></li>
+ <li><a href="https://www.linkedin.com/in/matthew-kosarek/">🏢 LinkedIn</a></li>
+ <li><a href='/posts.html'>&#128221; Posts</a></li>
+ </ul>
+ </nav>
+ </header>
+
+
+
+ <section>
+ <h2>Posts</h2>
+ <ul id='post_list'>
+
+ <li><a href="/posts//hello_world.html">Hello, World!</a></li>
+
+ </ul>
+ </section>
+ </body>
+</html>
diff --git a/posts/tag_personal.html b/posts/tag_personal.html
new file mode 100644
index 0000000..1999d78
--- /dev/null
+++ b/posts/tag_personal.html
@@ -0,0 +1,36 @@
+
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta charset="utf-8">
+ <link rel="stylesheet" href="/index.css">
+ <link rel="stylesheet" href="/posts.css">
+ <title>Matthew Kosarek</title>
+ <link rel="shortcut icon" href="/favicon/favicon.ico" type="image/x-icon">
+ </head>
+ <body>
+ <header>
+ <h1>Matthew Kosarek</h1>
+ <nav>
+ <ul>
+ <li><a href='/'>&#127969; Home</a></li>
+ <li><a href='/resume.html'>&#128216; CV</a></li>
+ <li><a href="https://www.linkedin.com/in/matthew-kosarek/">🏢 LinkedIn</a></li>
+ <li><a href='/posts.html'>&#128221; Posts</a></li>
+ </ul>
+ </nav>
+ </header>
+
+
+
+ <section>
+ <h2>Posts</h2>
+ <ul id='post_list'>
+
+ <li><a href="/posts//hello_world.html">Hello, World!</a></li>
+
+ </ul>
+ </section>
+ </body>
+</html>