Browse Source

chore: move posts to content/

restructure
Garrit Franke 4 years ago
parent
commit
312b0f8a1e
  1. 0
      content/posts/fighting-array-functions-with-es6.md
  2. 0
      content/posts/lightweight-vpn-with-wireguard.md
  3. 0
      content/posts/patch-based-git-workflow.md
  4. 0
      content/posts/quick-tip-terminal-pastebin.md
  5. 0
      content/posts/testing-isnt-hard.md
  6. 0
      content/posts/whom-do-you-trust.md
  7. 2
      pages/index.js
  8. 7
      pages/posts/[post].js

0
posts/fighting-array-functions-with-es6.md → content/posts/fighting-array-functions-with-es6.md

0
posts/lightweight-vpn-with-wireguard.md → content/posts/lightweight-vpn-with-wireguard.md

0
posts/patch-based-git-workflow.md → content/posts/patch-based-git-workflow.md

0
posts/quick-tip-terminal-pastebin.md → content/posts/quick-tip-terminal-pastebin.md

0
posts/testing-isnt-hard.md → content/posts/testing-isnt-hard.md

0
posts/whom-do-you-trust.md → content/posts/whom-do-you-trust.md

2
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: {

7
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

Loading…
Cancel
Save