mirror of
https://github.com/Unkn0wnCat/KevinK.dev.js.git
synced 2025-04-29 10:16:53 +02:00
Add way to disable site modules in config
This commit is contained in:
parent
a972bf6234
commit
f704547b25
8 changed files with 359 additions and 210 deletions
|
@ -3,6 +3,11 @@ module.exports = {
|
||||||
siteName: "KevinK.dev",
|
siteName: "KevinK.dev",
|
||||||
siteAuthor: "@Unkn0wnKevin",
|
siteAuthor: "@Unkn0wnKevin",
|
||||||
siteURL: "https://kevink.dev",
|
siteURL: "https://kevink.dev",
|
||||||
|
modules: {
|
||||||
|
blog: true,
|
||||||
|
projects: true,
|
||||||
|
donation: true,
|
||||||
|
},
|
||||||
payPalMail: "kevin@1in9.net",
|
payPalMail: "kevin@1in9.net",
|
||||||
siteKeywords:
|
siteKeywords:
|
||||||
"Kevin Kandlbinder, Kevin, Kandlbinder, Web, Web Developer, Developer, JavaScript, PHP, Java, Photos, Fotos",
|
"Kevin Kandlbinder, Kevin, Kandlbinder, Web, Web Developer, Developer, JavaScript, PHP, Java, Photos, Fotos",
|
||||||
|
|
175
gatsby-config.js
175
gatsby-config.js
|
@ -1,11 +1,101 @@
|
||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
const extConfig = require("./config");
|
const extConfig = require("./config");
|
||||||
|
|
||||||
|
const dynamicPlugins = [];
|
||||||
|
|
||||||
|
if (extConfig.modules.blog) {
|
||||||
|
dynamicPlugins.push({
|
||||||
|
resolve: `gatsby-plugin-feed`,
|
||||||
|
options: {
|
||||||
|
query: `
|
||||||
|
{
|
||||||
|
site {
|
||||||
|
siteMetadata {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
siteUrl
|
||||||
|
site_url: siteUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
feeds: [
|
||||||
|
{
|
||||||
|
serialize: ({ query: { site, blog } }) => {
|
||||||
|
return blog.nodes.map((node) => {
|
||||||
|
if (!node.childMdx) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: node.childMdx.frontmatter.title,
|
||||||
|
description: node.childMdx.excerpt,
|
||||||
|
date: node.childMdx.frontmatter.date,
|
||||||
|
url:
|
||||||
|
site.siteMetadata.siteUrl +
|
||||||
|
`/${
|
||||||
|
node.childMdx.frontmatter.language
|
||||||
|
}/blog/${
|
||||||
|
node.childMdx.frontmatter.section
|
||||||
|
? node.childMdx.frontmatter
|
||||||
|
.section + "/"
|
||||||
|
: ""
|
||||||
|
}${node.childMdx.frontmatter.published}/${
|
||||||
|
node.childMdx.frontmatter.url
|
||||||
|
}`,
|
||||||
|
guid:
|
||||||
|
site.siteMetadata.siteUrl +
|
||||||
|
`/${
|
||||||
|
node.childMdx.frontmatter.language
|
||||||
|
}/blog/${
|
||||||
|
node.childMdx.frontmatter.section
|
||||||
|
? node.childMdx.frontmatter
|
||||||
|
.section + "/"
|
||||||
|
: ""
|
||||||
|
}${node.childMdx.frontmatter.published}/${
|
||||||
|
node.childMdx.frontmatter.url
|
||||||
|
}`,
|
||||||
|
category: node.childMdx.frontmatter.section,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
query: `
|
||||||
|
{
|
||||||
|
blog: allFile(
|
||||||
|
filter: { sourceInstanceName: { eq: "blogContent" } }
|
||||||
|
) {
|
||||||
|
nodes {
|
||||||
|
childMdx {
|
||||||
|
id
|
||||||
|
body
|
||||||
|
excerpt
|
||||||
|
frontmatter {
|
||||||
|
platform
|
||||||
|
tags
|
||||||
|
title
|
||||||
|
url
|
||||||
|
section
|
||||||
|
language
|
||||||
|
published(formatString: "YYYY/MM")
|
||||||
|
date: published
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
output: "/blog/feed.rss",
|
||||||
|
title: extConfig.siteName + " Blog",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: extConfig.siteName,
|
title: extConfig.siteName,
|
||||||
author: extConfig.siteAuthor,
|
author: extConfig.siteAuthor,
|
||||||
siteUrl: extConfig.siteURL,
|
siteUrl: extConfig.siteURL,
|
||||||
|
modules: extConfig.modules,
|
||||||
keywords: extConfig.siteKeywords,
|
keywords: extConfig.siteKeywords,
|
||||||
payPalMail: extConfig.payPalMail,
|
payPalMail: extConfig.payPalMail,
|
||||||
contactEmail: extConfig.contactEmail,
|
contactEmail: extConfig.contactEmail,
|
||||||
|
@ -146,89 +236,6 @@ module.exports = {
|
||||||
generateMatchPathRewrites: false,
|
generateMatchPathRewrites: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
...dynamicPlugins,
|
||||||
resolve: `gatsby-plugin-feed`,
|
|
||||||
options: {
|
|
||||||
query: `
|
|
||||||
{
|
|
||||||
site {
|
|
||||||
siteMetadata {
|
|
||||||
title
|
|
||||||
description
|
|
||||||
siteUrl
|
|
||||||
site_url: siteUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
feeds: [
|
|
||||||
{
|
|
||||||
serialize: ({ query: { site, blog } }) => {
|
|
||||||
return blog.nodes.map((node) => {
|
|
||||||
if (!node.childMdx) return null;
|
|
||||||
|
|
||||||
return {
|
|
||||||
title: node.childMdx.frontmatter.title,
|
|
||||||
description: node.childMdx.excerpt,
|
|
||||||
date: node.childMdx.frontmatter.date,
|
|
||||||
url:
|
|
||||||
site.siteMetadata.siteUrl +
|
|
||||||
`/${
|
|
||||||
node.childMdx.frontmatter.language
|
|
||||||
}/blog/${
|
|
||||||
node.childMdx.frontmatter.section
|
|
||||||
? node.childMdx.frontmatter
|
|
||||||
.section + "/"
|
|
||||||
: ""
|
|
||||||
}${
|
|
||||||
node.childMdx.frontmatter.published
|
|
||||||
}/${node.childMdx.frontmatter.url}`,
|
|
||||||
guid:
|
|
||||||
site.siteMetadata.siteUrl +
|
|
||||||
`/${
|
|
||||||
node.childMdx.frontmatter.language
|
|
||||||
}/blog/${
|
|
||||||
node.childMdx.frontmatter.section
|
|
||||||
? node.childMdx.frontmatter
|
|
||||||
.section + "/"
|
|
||||||
: ""
|
|
||||||
}${
|
|
||||||
node.childMdx.frontmatter.published
|
|
||||||
}/${node.childMdx.frontmatter.url}`,
|
|
||||||
category: node.childMdx.frontmatter.section,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
},
|
|
||||||
query: `
|
|
||||||
{
|
|
||||||
blog: allFile(
|
|
||||||
filter: { sourceInstanceName: { eq: "blogContent" } }
|
|
||||||
) {
|
|
||||||
nodes {
|
|
||||||
childMdx {
|
|
||||||
id
|
|
||||||
body
|
|
||||||
excerpt
|
|
||||||
frontmatter {
|
|
||||||
platform
|
|
||||||
tags
|
|
||||||
title
|
|
||||||
url
|
|
||||||
section
|
|
||||||
language
|
|
||||||
published(formatString: "YYYY/MM")
|
|
||||||
date: published
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
output: "/blog/feed.rss",
|
|
||||||
title: extConfig.siteName + " Blog",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
325
gatsby-node.js
325
gatsby-node.js
|
@ -2,6 +2,8 @@
|
||||||
const path = require(`path`);
|
const path = require(`path`);
|
||||||
const { paginate } = require("gatsby-awesome-pagination");
|
const { paginate } = require("gatsby-awesome-pagination");
|
||||||
|
|
||||||
|
const { modules: moduleConfig, languages } = require("./config.js");
|
||||||
|
|
||||||
exports.createPages = async ({ actions, graphql, reporter }) => {
|
exports.createPages = async ({ actions, graphql, reporter }) => {
|
||||||
const { createPage, createRedirect } = actions;
|
const { createPage, createRedirect } = actions;
|
||||||
|
|
||||||
|
@ -48,129 +50,120 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.setStatus("Generating project pages...");
|
if (moduleConfig.projects) {
|
||||||
|
activity.setStatus("Generating project pages...");
|
||||||
|
|
||||||
result.data.allProjectsJson.nodes.forEach((node) => {
|
result.data.allProjectsJson.nodes.forEach((node) => {
|
||||||
if (node.lang === "ignoreme") return;
|
if (node.lang === "ignoreme") return;
|
||||||
|
|
||||||
reporter.info(
|
|
||||||
"Creating Page: " + `/${node.lang}/projects/${node.urlname}`
|
|
||||||
);
|
|
||||||
|
|
||||||
createPage({
|
|
||||||
path: `/${node.lang}/projects/${node.urlname}`,
|
|
||||||
component: projectTemplate,
|
|
||||||
context: {
|
|
||||||
lang: node.lang,
|
|
||||||
urlname: node.urlname,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
activity.setStatus("Generating blog pages...");
|
|
||||||
|
|
||||||
const blogListingTemplate = path.resolve(`src/templates/blogListing.js`);
|
|
||||||
const blogTemplate = path.resolve(`src/templates/blogPost.js`);
|
|
||||||
|
|
||||||
reporter.info("Creating blog listings...");
|
|
||||||
|
|
||||||
["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);
|
|
||||||
|
|
||||||
reporter.info(
|
reporter.info(
|
||||||
"Creating section listing for " +
|
"Creating Page: " + `/${node.lang}/projects/${node.urlname}`
|
||||||
node.childMdx.frontmatter.section +
|
|
||||||
"..."
|
|
||||||
);
|
);
|
||||||
|
|
||||||
["en", "de"].forEach((lang) =>
|
createPage({
|
||||||
paginate({
|
path: `/${node.lang}/projects/${node.urlname}`,
|
||||||
createPage,
|
component: projectTemplate,
|
||||||
items: result.data.blog.nodes.filter(
|
context: {
|
||||||
(e) =>
|
lang: node.lang,
|
||||||
e.childMdx.frontmatter.section ===
|
urlname: node.urlname,
|
||||||
node.childMdx.frontmatter.section
|
},
|
||||||
),
|
});
|
||||||
itemsPerPage: 10,
|
});
|
||||||
pathPrefix: `/${lang}/blog/${node.childMdx.frontmatter.section}`,
|
}
|
||||||
component: blogListingTemplate,
|
|
||||||
context: {
|
|
||||||
lang,
|
|
||||||
section: node.childMdx.frontmatter.section,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
reporter.info(
|
if (moduleConfig.blog) {
|
||||||
"Creating Page: " +
|
activity.setStatus("Generating blog pages...");
|
||||||
`/${node.childMdx.frontmatter.language}/blog/${
|
|
||||||
node.childMdx.frontmatter.section ?? "blog"
|
const blogListingTemplate = path.resolve(
|
||||||
}/${node.childMdx.frontmatter.url}`
|
`src/templates/blogListing.js`
|
||||||
|
);
|
||||||
|
const blogTemplate = path.resolve(`src/templates/blogPost.js`);
|
||||||
|
|
||||||
|
reporter.info("Creating blog listings...");
|
||||||
|
|
||||||
|
languages.forEach((lang) =>
|
||||||
|
paginate({
|
||||||
|
createPage,
|
||||||
|
items: result.data.blog.nodes,
|
||||||
|
itemsPerPage: 10,
|
||||||
|
pathPrefix: `/${lang}/blog`,
|
||||||
|
component: blogListingTemplate,
|
||||||
|
context: {
|
||||||
|
lang,
|
||||||
|
},
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
createPage({
|
let processedSections = ["blog"];
|
||||||
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) => {
|
result.data.blog.nodes.forEach((node) => {
|
||||||
if (lang === node.childMdx.frontmatter.language) return;
|
if (!node.childMdx) return;
|
||||||
|
|
||||||
createRedirect({
|
if (
|
||||||
fromPath: `/${lang}/blog/${
|
!processedSections.includes(
|
||||||
|
node.childMdx.frontmatter.section ?? "blog"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
processedSections.push(node.childMdx.frontmatter.section);
|
||||||
|
|
||||||
|
reporter.info(
|
||||||
|
"Creating section listing for " +
|
||||||
|
node.childMdx.frontmatter.section +
|
||||||
|
"..."
|
||||||
|
);
|
||||||
|
|
||||||
|
languages.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,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
reporter.info(
|
||||||
|
"Creating Page: " +
|
||||||
|
`/${node.childMdx.frontmatter.language}/blog/${
|
||||||
|
node.childMdx.frontmatter.section ?? "blog"
|
||||||
|
}/${node.childMdx.frontmatter.url}`
|
||||||
|
);
|
||||||
|
|
||||||
|
createPage({
|
||||||
|
path: `/${node.childMdx.frontmatter.language}/blog/${
|
||||||
node.childMdx.frontmatter.section
|
node.childMdx.frontmatter.section
|
||||||
? node.childMdx.frontmatter.section + "/"
|
? node.childMdx.frontmatter.section + "/"
|
||||||
: ""
|
: ""
|
||||||
}${node.childMdx.frontmatter.published}/${
|
}${node.childMdx.frontmatter.published}/${
|
||||||
node.childMdx.frontmatter.url
|
node.childMdx.frontmatter.url
|
||||||
}`,
|
}`,
|
||||||
toPath: `/${node.childMdx.frontmatter.language}/blog/${
|
component: blogTemplate,
|
||||||
node.childMdx.frontmatter.section
|
context: {
|
||||||
? node.childMdx.frontmatter.section + "/"
|
mdxId: node.childMdx.id,
|
||||||
: ""
|
lang: node.childMdx.frontmatter.language,
|
||||||
}${node.childMdx.frontmatter.published}/${
|
},
|
||||||
node.childMdx.frontmatter.url
|
|
||||||
}`,
|
|
||||||
redirectInBrowser: true,
|
|
||||||
permanent: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (node.childMdx.frontmatter.section === "scambox") {
|
languages.forEach((lang) => {
|
||||||
|
if (lang === node.childMdx.frontmatter.language) return;
|
||||||
|
|
||||||
createRedirect({
|
createRedirect({
|
||||||
fromPath: `/${lang}/scambox/${node.childMdx.frontmatter.url}`,
|
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/${
|
toPath: `/${node.childMdx.frontmatter.language}/blog/${
|
||||||
node.childMdx.frontmatter.section
|
node.childMdx.frontmatter.section
|
||||||
? node.childMdx.frontmatter.section + "/"
|
? node.childMdx.frontmatter.section + "/"
|
||||||
|
@ -181,10 +174,130 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
|
||||||
redirectInBrowser: true,
|
redirectInBrowser: true,
|
||||||
permanent: 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
activity.setStatus("Pages generated.");
|
activity.setStatus("Pages generated.");
|
||||||
activity.end();
|
activity.end();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.onCreatePage = ({ page, actions: { deletePage } }) => {
|
||||||
|
if (!moduleConfig.projects) {
|
||||||
|
if (page.path.startsWith("/projects")) {
|
||||||
|
deletePage(page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
languages.forEach((lng) => {
|
||||||
|
if (page.path.startsWith(`/${lng}/projects`)) {
|
||||||
|
deletePage(page);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!moduleConfig.donation) {
|
||||||
|
if (page.path.startsWith("/donate")) {
|
||||||
|
deletePage(page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
languages.forEach((lng) => {
|
||||||
|
if (page.path.startsWith(`/${lng}/donate`)) {
|
||||||
|
deletePage(page);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!moduleConfig.blog) {
|
||||||
|
if (page.path.startsWith("/blog")) {
|
||||||
|
deletePage(page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
languages.forEach((lng) => {
|
||||||
|
if (page.path.startsWith(`/${lng}/blog`)) {
|
||||||
|
deletePage(page);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.createSchemaCustomization = ({ actions }) => {
|
||||||
|
const { createTypes } = actions;
|
||||||
|
const typeDefs = `
|
||||||
|
type MultiLocaleString {
|
||||||
|
en: String
|
||||||
|
de: String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type CareerJson implements Node {
|
||||||
|
type: String
|
||||||
|
title: MultiLocaleString
|
||||||
|
sortDate(difference: String
|
||||||
|
formatString: String
|
||||||
|
fromNow: Boolean
|
||||||
|
locale: String): Date
|
||||||
|
startDate: MultiLocaleString
|
||||||
|
endDate: MultiLocaleString
|
||||||
|
description: MultiLocaleString
|
||||||
|
externalLink: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type FriendsJson implements Node {
|
||||||
|
profession: String
|
||||||
|
name: String
|
||||||
|
url: String
|
||||||
|
imageURL: String
|
||||||
|
localImage: File
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectsJsonLinks {
|
||||||
|
website: String
|
||||||
|
github: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectsJson implements Node {
|
||||||
|
urlname: String
|
||||||
|
lang: String
|
||||||
|
name: String
|
||||||
|
shortDescription: String
|
||||||
|
links: ProjectsJsonLinks
|
||||||
|
#image: File
|
||||||
|
featured: Int
|
||||||
|
date: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type SocialsJson implements Node {
|
||||||
|
platformName: String
|
||||||
|
platformHandle: String
|
||||||
|
url: String
|
||||||
|
image: String
|
||||||
|
localImage: File
|
||||||
|
}
|
||||||
|
|
||||||
|
type SkillsJson implements Node {
|
||||||
|
name: String
|
||||||
|
href: String
|
||||||
|
type: String
|
||||||
|
}
|
||||||
|
|
||||||
|
`;
|
||||||
|
createTypes(typeDefs);
|
||||||
|
};
|
||||||
|
|
|
@ -7,12 +7,15 @@ import { graphql, StaticQuery } from "gatsby";
|
||||||
import * as styles from "./navigation.module.scss";
|
import * as styles from "./navigation.module.scss";
|
||||||
import { Fade as Hamburger } from "hamburger-react";
|
import { Fade as Hamburger } from "hamburger-react";
|
||||||
import OffScreenNav from "./offscreenNav";
|
import OffScreenNav from "./offscreenNav";
|
||||||
|
import useSiteMetadata from "../helpers/useSiteMetadata";
|
||||||
|
|
||||||
const Navigation = ({ isHome }) => {
|
const Navigation = ({ isHome }) => {
|
||||||
let [atTop, setAtTop] = useState(false);
|
let [atTop, setAtTop] = useState(false);
|
||||||
const [offscreenNavActive, setOffscreenNavActive] = useState(false);
|
const [offscreenNavActive, setOffscreenNavActive] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { modules } = useSiteMetadata();
|
||||||
|
|
||||||
const closeOffscreenNav = () => setOffscreenNavActive(false);
|
const closeOffscreenNav = () => setOffscreenNavActive(false);
|
||||||
|
|
||||||
const updateTransparency = () => {
|
const updateTransparency = () => {
|
||||||
|
@ -87,15 +90,19 @@ const Navigation = ({ isHome }) => {
|
||||||
<Link to="/about" activeClassName={styles.active}>
|
<Link to="/about" activeClassName={styles.active}>
|
||||||
<Trans>about.title</Trans>
|
<Trans>about.title</Trans>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/projects" activeClassName={styles.active}>
|
{modules.projects && (
|
||||||
<Trans>project.plural</Trans>
|
<Link to="/projects" activeClassName={styles.active}>
|
||||||
</Link>
|
<Trans>project.plural</Trans>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
<Link to="/social" activeClassName={styles.active}>
|
<Link to="/social" activeClassName={styles.active}>
|
||||||
<Trans>social.title</Trans>
|
<Trans>social.title</Trans>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/blog" activeClassName={styles.active}>
|
{modules.blog && (
|
||||||
<Trans>blog.title</Trans>
|
<Link to="/blog" activeClassName={styles.active}>
|
||||||
</Link>
|
<Trans>blog.title</Trans>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
<div className={styles.hamburger}>
|
<div className={styles.hamburger}>
|
||||||
<Hamburger
|
<Hamburger
|
||||||
toggle={setOffscreenNavActive}
|
toggle={setOffscreenNavActive}
|
||||||
|
|
|
@ -6,9 +6,12 @@ import { createPortal } from "react-dom";
|
||||||
|
|
||||||
import * as styles from "./navigation.module.scss";
|
import * as styles from "./navigation.module.scss";
|
||||||
import { X } from "lucide-react";
|
import { X } from "lucide-react";
|
||||||
|
import useSiteMetadata from "../helpers/useSiteMetadata";
|
||||||
|
|
||||||
const OffScreenNav = ({ active, close }) => {
|
const OffScreenNav = ({ active, close }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { modules } = useSiteMetadata();
|
||||||
|
|
||||||
if (typeof document === "undefined") return <></>;
|
if (typeof document === "undefined") return <></>;
|
||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
|
@ -34,15 +37,19 @@ const OffScreenNav = ({ active, close }) => {
|
||||||
<Link to="/about" activeClassName={styles.active}>
|
<Link to="/about" activeClassName={styles.active}>
|
||||||
<Trans>about.title</Trans>
|
<Trans>about.title</Trans>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/projects" activeClassName={styles.active}>
|
{modules.projects && (
|
||||||
<Trans>project.plural</Trans>
|
<Link to="/projects" activeClassName={styles.active}>
|
||||||
</Link>
|
<Trans>project.plural</Trans>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
<Link to="/social" activeClassName={styles.active}>
|
<Link to="/social" activeClassName={styles.active}>
|
||||||
<Trans>social.title</Trans>
|
<Trans>social.title</Trans>
|
||||||
</Link>
|
</Link>
|
||||||
<Link to="/blog" activeClassName={styles.active}>
|
{modules.blog && (
|
||||||
<Trans>blog.title</Trans>
|
<Link to="/blog" activeClassName={styles.active}>
|
||||||
</Link>
|
<Trans>blog.title</Trans>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>,
|
</div>,
|
||||||
document.getElementById("osnav")
|
document.getElementById("osnav")
|
||||||
|
|
|
@ -26,6 +26,11 @@ const useSiteMetadata = () => {
|
||||||
height
|
height
|
||||||
nationality
|
nationality
|
||||||
sameAs
|
sameAs
|
||||||
|
modules {
|
||||||
|
blog
|
||||||
|
projects
|
||||||
|
donation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {
|
||||||
Loader,
|
Loader,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import useSiteMetadata from "../helpers/useSiteMetadata";
|
||||||
|
|
||||||
export const query = graphql`
|
export const query = graphql`
|
||||||
query GetProjectsAndSkills($language: String) {
|
query GetProjectsAndSkills($language: String) {
|
||||||
|
@ -98,6 +99,7 @@ export const query = graphql`
|
||||||
|
|
||||||
const AboutPage = (props) => {
|
const AboutPage = (props) => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
const { modules } = useSiteMetadata();
|
||||||
|
|
||||||
let file = props.data.file;
|
let file = props.data.file;
|
||||||
|
|
||||||
|
@ -291,14 +293,16 @@ const AboutPage = (props) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<Link className={styles.donationSection} to="/donate">
|
{modules.donation && (
|
||||||
<div>
|
<Link className={styles.donationSection} to="/donate">
|
||||||
<span>
|
<div>
|
||||||
<Trans>about.donationCatchphrase</Trans>
|
<span>
|
||||||
</span>
|
<Trans>about.donationCatchphrase</Trans>
|
||||||
<ArrowRight />
|
</span>
|
||||||
</div>
|
<ArrowRight />
|
||||||
</Link>
|
</div>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,6 +45,7 @@ export const query = graphql`
|
||||||
const ProjectsPage = ({ data }) => {
|
const ProjectsPage = ({ data }) => {
|
||||||
const { t } = useI18next();
|
const { t } = useI18next();
|
||||||
const meta = useSiteMetadata();
|
const meta = useSiteMetadata();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
title={t("project.plural")}
|
title={t("project.plural")}
|
||||||
|
|
Loading…
Add table
Reference in a new issue