Skip to content

Commit

Permalink
Merge pull request #219 from NobbZ/192-add-author-to-article-and-prev…
Browse files Browse the repository at this point in the history
…iew-pages
  • Loading branch information
NobbZ committed Jul 3, 2023
2 parents f00560d + 49d4ab5 commit aa384c1
Show file tree
Hide file tree
Showing 26 changed files with 1,078 additions and 194 deletions.
73 changes: 73 additions & 0 deletions author/nobbz.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
slug: "nobbz"
first_name: "Norbert"
last_name: "Melzer"
nick_name: "NobbZ"
social:
amazon: "https://www.amazon.de/hz/wishlist/ls/1GZRUIT9EP93R?ref_=wl_share"
github: "NobbZ"
gitlab: "NobbZ"
ko-fi: "nobbz"
linkedin: "norbert-melzer-a175829a"
twitter: "NobbZ1981"
web:
url: "https://blog.nobbz.dev/"
name: "NobbZ Blog"
---

Norbert is a software developer from Germany, whos primary language is [Elixir].

[Elixir]: https://elixir-lang.org/

His strong interest in Elixir began during his studies somewhen in 2014, when
he wanted to use a "functional alternative to [Ruby]" in a programming contest at
the university.

[Ruby]: https://www.ruby-lang.org/

When he wanted to test his contestant on the designated machine, he found out
that the erlang version installed did not support any released version of Elixir,
so he had to rewrite his contestant in [Erlang].

[Erlang]: https://www.erlang.org/

For a long time he used both languages in parallel, and became an Erlang track
maintainer at [Exercism] during 2015, where he still is. Within the same year
he also became a member and moderator of the [Elixir Forum], where he is still
active as well.

[Exercism]: https://exercism.org/
[Elixir Forum]: https://elixirforum.com/

In 2016 he started to work professionally to be able to pay for his university.
During that job he used mostly [Go] and [Python], though was able to use any
language necessary to get the job done.

[Go]: https://golang.org/
[Python]: https://www.python.org/

This did include [PHP], [Java], [C++], and [JavaScript] as well.

[PHP]: https://www.php.net/
[Java]: https://www.java.com/
[C++]: https://isocpp.org/
[JavaScript]: https://www.javascript.com/

In 2022 he finally was able to find a job where he was able to use Elixir
professionally, and is now working as a backend developer.

Besides of doing software development, he is also a passionate user of [NixOS].
He currently maintains a few packages in the official repository, and is
also using it on his 2 private machines. He also plays with [`nix`] on a virtual
machine on his work laptop (Apple).

[NixOS]: https://nixos.org/
[`nix`]: https://nixos.org/manual/nix/stable/#ch-about-nix

For all the `nix` related things he is also active on the [NixOS Discourse] and
the inofficial [NixOS Discord].

[NixOS Discourse]: https://discourse.nixos.org/
[NixOS Discord]: https://discord.gg/fFQp8hqY

Besides all his technical hobbies, he also is a father of 2 children.
1 change: 1 addition & 0 deletions blog/001-hello-world/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tags:
- elixir
- erlang
- javascript
author: "nobbz"
---

This is mainly a short post to see whether or not the infrastructure is working
Expand Down
1 change: 1 addition & 0 deletions blog/002-callpackage-a-tool-for-the-lazy/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ hero_image_alt: A cat sleeping under a blanket
hero_image_credit: Kate Stone Matheson on Unsplash
hero_image_credit_link: https://unsplash.com/@kstonematheson
hero_image_link: https://unsplash.com/photos/uy5t-CJuIK4
author: "nobbz"
tags:
- nix
- callPkgs
Expand Down
1 change: 1 addition & 0 deletions blog/003-getting-inputs-to-modules-in-a-flake/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ hero_image_alt: Close-up of the Enter key on a laptop
hero_image_credit: Arthur Mazi on Unsplash
hero_image_credit_link: https://unsplash.com/@arthurbizkit
hero_image_link: https://unsplash.com/photos/fEXeyNYmO2Y
author: "nobbz"
tags:
- nix
- flake
Expand Down
1 change: 1 addition & 0 deletions blog/004-12in23/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ hero_image_alt: A hand trying to pick a numerical lock with a toothpick
hero_image_credit: Ariel on Unsplash
hero_image_credit_link: https://unsplash.com/@arielbesagar
hero_image_link: https://unsplash.com/photos/Oal07Ai4oTk
author: "nobbz"
tags:
- exercism
- 12in23
Expand Down
1 change: 1 addition & 0 deletions blog/005-nixos-flakes-command-not-found/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ hero_image_alt: Close-up of a snowflake on black whool
hero_image_credit: Darius Cotoi on Unsplash
hero_image_credit_link: https://unsplash.com/@dariuscotoi
hero_image_link: https://unsplash.com/photos/wzemAWJGc8E
author: "nobbz"
tags:
- nixos
- flakes
Expand Down
10 changes: 10 additions & 0 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ const config: GatsbyConfig = {
"gatsby-plugin-mdx",
"gatsby-plugin-postcss",
"gatsby-plugin-readtime-nz",
"gatsby-plugin-mdx-source-name",
"gatsby-transformer-nz-author",
"gatsby-transformer-nz-blog",
{
resolve: "gatsby-source-filesystem",
options: {
name: "blog",
path: `${__dirname}/blog`,
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "author",
path: `${__dirname}/author`,
},
},
],
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"gatsby": "^5.10.0",
"gatsby-plugin-image": "^3.10.0",
"gatsby-plugin-mdx": "^5.10.0",
"gatsby-plugin-mdx-source-name": "^1.0.1",
"gatsby-plugin-sharp": "^5.10.0",
"gatsby-plugin-sitemap": "^6.10.0",
"gatsby-remark-highlight-code": "^3.3.0",
Expand Down
2 changes: 0 additions & 2 deletions plugins/gatsby-plugin-readtime-nz/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const onCreateNode: GatsbyNode<IMdxNode>["onCreateNode"] = (

const { wordsPerMinute = 200, language = "en" } = options;

console.log("node", node);

createNodeField({
node,
name: "readingTime",
Expand Down
67 changes: 67 additions & 0 deletions plugins/gatsby-transformer-nz-author/gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { GatsbyNode, NodeInput } from "gatsby";

import { IMdxNode } from "gatsby-plugin-mdx/dist/types";

interface AuthorParentNode extends IMdxNode {
parent: string;
fields: { readingTime: unknown };
frontmatter: {
slug: string;
first_name?: string;
last_name?: string;
nick_name?: string;
social?: Record<string, string | Record<string, unknown>>;
};
}

export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"] =
({ actions }) => {
const { createTypes } = actions;

createTypes(`
type Author implements Node {
slug: String!
firstName: String!
lastName: String!
nickName: String
social: JSON
articles: [Blog] @link(by: "author.slug", from: "slug")
}
`);
};

export const shouldOnCreateNode: GatsbyNode<IMdxNode>["shouldOnCreateNode"] = ({
node,
}) => {
return (
node.internal.type === "Mdx" &&
!!node.parent &&
// node.parent.sourceInstanceName === "author"
(node.fields as undefined | { source: string })?.source === "author"
);
};

export const onCreateNode: GatsbyNode<AuthorParentNode>["onCreateNode"] = ({
node,
actions,
createNodeId,
}) => {
const { createNode, createParentChildLink } = actions;

const authorNode: NodeInput = {
id: createNodeId(`${node.id} >>> author`),
internal: {
type: "Author",
contentDigest: node.internal.contentDigest,
contentFilePath: node.internal.contentFilePath,
},
slug: node.frontmatter.slug,
firstName: node.frontmatter.first_name,
lastName: node.frontmatter.last_name,
nickName: node.frontmatter.nick_name,
social: node.frontmatter.social,
};

createNode(authorNode);
createParentChildLink({ parent: node, child: authorNode });
};
5 changes: 5 additions & 0 deletions plugins/gatsby-transformer-nz-author/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "gatsby-transformer-nz-author",
"version": "1.0.0",
"private": true
}
93 changes: 93 additions & 0 deletions plugins/gatsby-transformer-nz-blog/gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { GatsbyNode, NodeInput } from "gatsby";

import { IMdxNode } from "gatsby-plugin-mdx/dist/types";
import { FileSystemNode } from "gatsby-source-filesystem";

interface BlogParentNode extends IMdxNode {
parent: string;
fields: { readingTime: unknown };
frontmatter: {
author: string;
title: string;
slug: string;
date: Date;
tags: string[];
hero_image_alt: string;
hero_image_link: string;
hero_image_credit_link: string;
hero_image_credit: string;
hero_image: FileSystemNode;
};
}

export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"] =
({ actions }) => {
const { createTypes } = actions;

createTypes(`
type HeroImageData {
alt: String!
link: String!
credit: String!
creditLink: String!
}
type Blog implements Node {
title: String!
author: Author @link(by: "slug")
slug: String!
date: Date!
tags: [String!]!
heroImage: HeroImageData!
excerpt: String
}
`);
};

export const shouldOnCreateNode: GatsbyNode<IMdxNode>["shouldOnCreateNode"] = ({
node,
}) => {
return (
node.internal.type === "Mdx" &&
!!node.parent &&
// node.parent.sourceInstanceName === "blog"
(node.fields as undefined | { source: string })?.source === "blog"
);
};

export const onCreateNode: GatsbyNode<BlogParentNode>["onCreateNode"] = async ({
node,
actions,
createNodeId,
}) => {
const { createNode, createParentChildLink } = actions;

const blogNode: NodeInput = {
id: createNodeId(`${node.id} >>> blog`),
children: [],
parent: node.id,
internal: {
type: "Blog",
contentDigest: node.internal.contentDigest,
contentFilePath: node.internal.contentFilePath,
},
title: node.frontmatter.title,
slug: node.frontmatter.slug,
date: node.frontmatter.date,
tags: node.frontmatter.tags,
author: node.frontmatter.author,
// TODO: Excerpt seems to be generated lazily on query time, so we need to re-map a resolver later
excerpt: "",
readingTime: node.fields.readingTime,
heroImage: {
alt: node.frontmatter.hero_image_alt,
link: node.frontmatter.hero_image_link,
creditLink: node.frontmatter.hero_image_credit_link,
credit: node.frontmatter.hero_image_credit,
image: node.frontmatter.hero_image as FileSystemNode,
},
};

createNode(blogNode);
createParentChildLink({ parent: node, child: blogNode });
};
5 changes: 5 additions & 0 deletions plugins/gatsby-transformer-nz-blog/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "gatsby-transformer-nz-blog",
"version": "1.0.0",
"private": true
}
Loading

0 comments on commit aa384c1

Please sign in to comment.