{t("scambox")}
- -{t("scamboxDescription")}
- -diff --git a/content/scambox/001-hermine.mdx b/content/blog/scambox/001-hermine.mdx
similarity index 87%
rename from content/scambox/001-hermine.mdx
rename to content/blog/scambox/001-hermine.mdx
index c1f4c23..1045c7a 100644
--- a/content/scambox/001-hermine.mdx
+++ b/content/blog/scambox/001-hermine.mdx
@@ -1,9 +1,13 @@
---
+section: scambox
+language: en
title: Harry Potter and the Toaster-Investment
url: harry-potter-and-the-toaster
platform: telegram
tags: [crypto]
published: 2021-11-05 22:00:00
+author:
+ name: Kevin Kandlbinder
---
I've recently been contacted by Hermine on Telegram with a big business opportunity,
diff --git a/gatsby-config.js b/gatsby-config.js
index 213c95a..1246eca 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -69,8 +69,8 @@ module.exports = {
{
resolve: `gatsby-source-filesystem`,
options: {
- path: `${__dirname}/content/scambox`,
- name: `scamboxContent`,
+ path: `${__dirname}/content/blog`,
+ name: `blogContent`,
},
},
"gatsby-plugin-mdx",
@@ -128,8 +128,8 @@ module.exports = {
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
- keySeparator: false,
- nsSeparator: false,
+ keySeparator: ".",
+ nsSeparator: ":",
},
pages: [
{
@@ -137,8 +137,14 @@ module.exports = {
getLanguageFromPath: true,
excludeLanguages: extConfig.languages,
},
+ {
+ matchPath: "/:lang/blog/:urlname*",
+ getLanguageFromPath: true,
+ excludeLanguages: extConfig.languages,
+ },
],
},
},
+ `gatsby-plugin-netlify`,
],
};
diff --git a/gatsby-node.js b/gatsby-node.js
index 6985ce3..bc4f5ca 100644
--- a/gatsby-node.js
+++ b/gatsby-node.js
@@ -1,12 +1,12 @@
/* eslint-disable no-undef */
const path = require(`path`);
const fs = require("fs");
+const { paginate } = require("gatsby-awesome-pagination");
exports.createPages = async ({ actions, graphql, reporter }) => {
- const { createPage } = actions;
+ const { createPage, createRedirect } = actions;
const projectTemplate = path.resolve(`src/templates/project.js`);
- const scamboxTemplate = path.resolve(`src/templates/scamboxPost.js`);
const result = await graphql(`
query AllPagesQuery {
@@ -17,8 +17,8 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
}
}
- scambox: allFile(
- filter: { sourceInstanceName: { eq: "scamboxContent" } }
+ blog: allFile(
+ filter: { sourceInstanceName: { eq: "blogContent" } }
) {
nodes {
childMdx {
@@ -29,6 +29,9 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
tags
title
url
+ section
+ language
+ published(formatString: "YYYY/MM")
}
}
}
@@ -59,24 +62,121 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
});
});
- result.data.scambox.nodes.forEach((node) => {
+ const blogListingTemplate = path.resolve(`src/templates/blogListing.js`);
+ const blogTemplate = path.resolve(`src/templates/blogPost.js`);
+
+ console.log("Creating blog listing...");
+
+ ["en", "de"].forEach((lang) =>
+ paginate({
+ createPage,
+ items: result.data.blog.nodes,
+ itemsPerPage: 10,
+ pathPrefix: `/${lang}/blog`,
+ component: blogListingTemplate,
+ context: {
+ lang,
+ },
+ })
+ );
+
+ let processedSections = ["blog"];
+
+ result.data.blog.nodes.forEach((node) => {
if (!node.childMdx) return;
+ if (
+ !processedSections.includes(
+ node.childMdx.frontmatter.section ?? "blog"
+ )
+ ) {
+ processedSections.push(node.childMdx.frontmatter.section);
+
+ console.log(
+ "Creating section listing for " +
+ node.childMdx.frontmatter.section +
+ "..."
+ );
+
+ ["en", "de"].forEach((lang) =>
+ paginate({
+ createPage,
+ items: result.data.blog.nodes.filter(
+ (e) =>
+ e.childMdx.frontmatter.section ===
+ node.childMdx.frontmatter.section
+ ),
+ itemsPerPage: 10,
+ pathPrefix: `/${lang}/blog/${node.childMdx.frontmatter.section}`,
+ component: blogListingTemplate,
+ context: {
+ lang,
+ section: node.childMdx.frontmatter.section,
+ },
+ })
+ );
+ }
+
// eslint-disable-next-line no-undef
console.log(
"Creating Page: ",
- `/*/scambox/${node.childMdx.frontmatter.url}`
+ `/${node.childMdx.frontmatter.language}/blog/${
+ node.childMdx.frontmatter.section ?? "blog"
+ }/${node.childMdx.frontmatter.url}`
);
- //["en", "de"].forEach((lang) => {
createPage({
- path: `/scambox/${node.childMdx.frontmatter.url}`,
- component: scamboxTemplate,
+ path: `/${node.childMdx.frontmatter.language}/blog/${
+ node.childMdx.frontmatter.section
+ ? node.childMdx.frontmatter.section + "/"
+ : ""
+ }${node.childMdx.frontmatter.published}/${
+ node.childMdx.frontmatter.url
+ }`,
+ component: blogTemplate,
context: {
mdxId: node.childMdx.id,
+ lang: node.childMdx.frontmatter.language,
},
});
- //})
+
+ ["en", "de"].forEach((lang) => {
+ if (lang === node.childMdx.frontmatter.language) return;
+
+ createRedirect({
+ fromPath: `/${lang}/blog/${
+ node.childMdx.frontmatter.section
+ ? node.childMdx.frontmatter.section + "/"
+ : ""
+ }${node.childMdx.frontmatter.published}/${
+ node.childMdx.frontmatter.url
+ }`,
+ toPath: `/${node.childMdx.frontmatter.language}/blog/${
+ node.childMdx.frontmatter.section
+ ? node.childMdx.frontmatter.section + "/"
+ : ""
+ }${node.childMdx.frontmatter.published}/${
+ node.childMdx.frontmatter.url
+ }`,
+ redirectInBrowser: true,
+ permanent: true,
+ });
+
+ if (node.childMdx.frontmatter.section === "scambox") {
+ createRedirect({
+ fromPath: `/${lang}/scambox/${node.childMdx.frontmatter.url}`,
+ toPath: `/${node.childMdx.frontmatter.language}/blog/${
+ node.childMdx.frontmatter.section
+ ? node.childMdx.frontmatter.section + "/"
+ : ""
+ }${node.childMdx.frontmatter.published}/${
+ node.childMdx.frontmatter.url
+ }`,
+ redirectInBrowser: true,
+ permanent: true,
+ });
+ }
+ });
});
};
diff --git a/locales/en/translation.json b/locales/en/translation.json
index aa1c999..a604363 100644
--- a/locales/en/translation.json
+++ b/locales/en/translation.json
@@ -48,5 +48,31 @@
"scamboxDescription": "Take a dive with me into all of the scams I get on the daily, and maybe laugh at them a little!",
"scamboxReadFull": "Read full post »",
"scamboxPosted": "Posted on {{date}}",
- "moreSoon": "More to come"
+ "moreSoon": "More to come",
+ "language": {
+ "en": {
+ "name": "English"
+ },
+ "de": {
+ "name": "German"
+ }
+ },
+ "blog": {
+ "title": "Blog",
+ "readFull": "Read full post »",
+ "meta": "Posted on {{date}} by {{author}}",
+ "page": "Page {{page}}/{{maxPage}}",
+ "previous": "Previous",
+ "next": "Next",
+ "section": {
+ "blog": {
+ "name": "Blog",
+ "description": "Read all about my exciting life!"
+ },
+ "scambox": {
+ "name": "Scambox",
+ "description": "Take a dive with me into all of the scams I get on the daily, and maybe laugh at them a little!"
+ }
+ }
+ }
}
diff --git a/package.json b/package.json
index 82f9b27..e0ab204 100644
--- a/package.json
+++ b/package.json
@@ -27,11 +27,13 @@
"animejs": "3.2.1",
"babel-plugin-i18next-extract": "0.8.3",
"gatsby": "4.1.0",
+ "gatsby-awesome-pagination": "^0.3.8",
"gatsby-cli": "4.1.0",
"gatsby-plugin-asset-path": "3.0.4",
"gatsby-plugin-image": "2.1.0",
"gatsby-plugin-manifest": "4.1.0",
"gatsby-plugin-mdx": "3.1.0",
+ "gatsby-plugin-netlify": "^3.14.0",
"gatsby-plugin-offline": "5.1.0",
"gatsby-plugin-portal": "1.0.7",
"gatsby-plugin-react-helmet": "5.1.0",
diff --git a/src/components/navigation.js b/src/components/navigation.js
index 358176e..67f3734 100644
--- a/src/components/navigation.js
+++ b/src/components/navigation.js
@@ -105,11 +105,11 @@ const Navigation = ({ isHome }) => {
{t("scamboxDescription")}
- -{description}
+ + {!hasSection && ( + <> +{t("scamboxLanguage")}
-