Add way to disable site modules in config

This commit is contained in:
Kevin Kandlbinder 2021-12-13 17:17:17 +00:00 committed by GitHub
parent a972bf6234
commit f704547b25
8 changed files with 359 additions and 210 deletions

View file

@ -7,12 +7,15 @@ import { graphql, StaticQuery } from "gatsby";
import * as styles from "./navigation.module.scss";
import { Fade as Hamburger } from "hamburger-react";
import OffScreenNav from "./offscreenNav";
import useSiteMetadata from "../helpers/useSiteMetadata";
const Navigation = ({ isHome }) => {
let [atTop, setAtTop] = useState(false);
const [offscreenNavActive, setOffscreenNavActive] = useState(false);
const { t } = useTranslation();
const { modules } = useSiteMetadata();
const closeOffscreenNav = () => setOffscreenNavActive(false);
const updateTransparency = () => {
@ -87,15 +90,19 @@ const Navigation = ({ isHome }) => {
<Link to="/about" activeClassName={styles.active}>
<Trans>about.title</Trans>
</Link>
<Link to="/projects" activeClassName={styles.active}>
<Trans>project.plural</Trans>
</Link>
{modules.projects && (
<Link to="/projects" activeClassName={styles.active}>
<Trans>project.plural</Trans>
</Link>
)}
<Link to="/social" activeClassName={styles.active}>
<Trans>social.title</Trans>
</Link>
<Link to="/blog" activeClassName={styles.active}>
<Trans>blog.title</Trans>
</Link>
{modules.blog && (
<Link to="/blog" activeClassName={styles.active}>
<Trans>blog.title</Trans>
</Link>
)}
<div className={styles.hamburger}>
<Hamburger
toggle={setOffscreenNavActive}

View file

@ -6,9 +6,12 @@ import { createPortal } from "react-dom";
import * as styles from "./navigation.module.scss";
import { X } from "lucide-react";
import useSiteMetadata from "../helpers/useSiteMetadata";
const OffScreenNav = ({ active, close }) => {
const { t } = useTranslation();
const { modules } = useSiteMetadata();
if (typeof document === "undefined") return <></>;
return createPortal(
@ -34,15 +37,19 @@ const OffScreenNav = ({ active, close }) => {
<Link to="/about" activeClassName={styles.active}>
<Trans>about.title</Trans>
</Link>
<Link to="/projects" activeClassName={styles.active}>
<Trans>project.plural</Trans>
</Link>
{modules.projects && (
<Link to="/projects" activeClassName={styles.active}>
<Trans>project.plural</Trans>
</Link>
)}
<Link to="/social" activeClassName={styles.active}>
<Trans>social.title</Trans>
</Link>
<Link to="/blog" activeClassName={styles.active}>
<Trans>blog.title</Trans>
</Link>
{modules.blog && (
<Link to="/blog" activeClassName={styles.active}>
<Trans>blog.title</Trans>
</Link>
)}
</div>
</div>,
document.getElementById("osnav")

View file

@ -26,6 +26,11 @@ const useSiteMetadata = () => {
height
nationality
sameAs
modules {
blog
projects
donation
}
}
}
}

View file

@ -18,6 +18,7 @@ import {
Loader,
} from "lucide-react";
import { useTranslation } from "react-i18next";
import useSiteMetadata from "../helpers/useSiteMetadata";
export const query = graphql`
query GetProjectsAndSkills($language: String) {
@ -98,6 +99,7 @@ export const query = graphql`
const AboutPage = (props) => {
const { t, i18n } = useTranslation();
const { modules } = useSiteMetadata();
let file = props.data.file;
@ -291,14 +293,16 @@ const AboutPage = (props) => {
</div>
</div>
</section>
<Link className={styles.donationSection} to="/donate">
<div>
<span>
<Trans>about.donationCatchphrase</Trans>
</span>
<ArrowRight />
</div>
</Link>
{modules.donation && (
<Link className={styles.donationSection} to="/donate">
<div>
<span>
<Trans>about.donationCatchphrase</Trans>
</span>
<ArrowRight />
</div>
</Link>
)}
</Layout>
);
};

View file

@ -45,6 +45,7 @@ export const query = graphql`
const ProjectsPage = ({ data }) => {
const { t } = useI18next();
const meta = useSiteMetadata();
return (
<Layout
title={t("project.plural")}