diff --git a/posts/fighting-array-functions-with-es6.md b/content/posts/fighting-array-functions-with-es6.md similarity index 100% rename from posts/fighting-array-functions-with-es6.md rename to content/posts/fighting-array-functions-with-es6.md diff --git a/posts/lightweight-vpn-with-wireguard.md b/content/posts/lightweight-vpn-with-wireguard.md similarity index 100% rename from posts/lightweight-vpn-with-wireguard.md rename to content/posts/lightweight-vpn-with-wireguard.md diff --git a/posts/patch-based-git-workflow.md b/content/posts/patch-based-git-workflow.md similarity index 100% rename from posts/patch-based-git-workflow.md rename to content/posts/patch-based-git-workflow.md diff --git a/posts/quick-tip-terminal-pastebin.md b/content/posts/quick-tip-terminal-pastebin.md similarity index 100% rename from posts/quick-tip-terminal-pastebin.md rename to content/posts/quick-tip-terminal-pastebin.md diff --git a/posts/testing-isnt-hard.md b/content/posts/testing-isnt-hard.md similarity index 100% rename from posts/testing-isnt-hard.md rename to content/posts/testing-isnt-hard.md diff --git a/posts/whom-do-you-trust.md b/content/posts/whom-do-you-trust.md similarity index 100% rename from posts/whom-do-you-trust.md rename to content/posts/whom-do-you-trust.md diff --git a/pages/index.js b/pages/index.js index 0551c96..0ac0f5a 100644 --- a/pages/index.js +++ b/pages/index.js @@ -35,7 +35,7 @@ export async function getStaticProps() { }; }); return data; - })(require.context("../posts", true, /\.md$/)); + })(require.context("../content/posts", true, /\.md$/)); return { props: { diff --git a/pages/posts/[post].js b/pages/posts/[post].js index e7b4422..bac1a02 100644 --- a/pages/posts/[post].js +++ b/pages/posts/[post].js @@ -2,7 +2,6 @@ import matter from "gray-matter"; import ReactMarkdown from "react-markdown"; import Layout from "../../components/Layout"; import glob from "glob"; -import { useRouter } from "next/router"; export default function BlogTemplate(props) { function reformatDate(fullDate) { @@ -163,7 +162,7 @@ export default function BlogTemplate(props) { export async function getStaticProps({ ...ctx }) { const { post } = ctx.params; - const content = await import(`../../posts/${post}.md`); + const content = await import(`../../content/posts/${post}.md`); const data = matter(content.default); return { @@ -177,11 +176,11 @@ export async function getStaticProps({ ...ctx }) { export async function getStaticPaths() { //get all .md files in the posts dir - const blogs = glob.sync("posts/**/*.md"); + const blogs = glob.sync("content/posts/**/*.md"); //remove path and extension to leave filename only const blogSlugs = blogs.map((file) => - file.split("/")[1].replace(/ /g, "-").slice(0, -3).trim() + file.split("/")[2].replace(/ /g, "-").slice(0, -3).trim() ); // create paths with `slug` param