Skip to content

Commit

Permalink
Add pages, animation, content and improve overall layout (#4)
Browse files Browse the repository at this point in the history
* add locale creation

Signed-off-by: Max Wolfs <[email protected]>

* add templates per post ype

Signed-off-by: Max Wolfs <[email protected]>

* add news page

Signed-off-by: Max Wolfs <[email protected]>

* fix menu link

Signed-off-by: Max Wolfs <[email protected]>

* fix translations

Signed-off-by: Max Wolfs <[email protected]>

* refactor list and improve responsiveness

Signed-off-by: Max Wolfs <[email protected]>

* fix translations

Signed-off-by: Max Wolfs <[email protected]>

* fixes

Signed-off-by: Max Wolfs <[email protected]>

* update single item page

Signed-off-by: Max Wolfs <[email protected]>

* update

Signed-off-by: Max Wolfs <[email protected]>

* fix post query on locale

Signed-off-by: Max Wolfs <[email protected]>

* add content and fixes

Signed-off-by: Max Wolfs <[email protected]>

* add footer, content, templates and routing

Signed-off-by: Max Wolfs <[email protected]>

* update layout

Signed-off-by: Max Wolfs <[email protected]>

* refactor backgroud animation

Signed-off-by: Max Wolfs <[email protected]>

* update

Signed-off-by: Max Wolfs <[email protected]>

* remove DS_Store

Signed-off-by: Max Wolfs <[email protected]>

* fixes

Signed-off-by: Max Wolfs <[email protected]>

* add remanining pages

Signed-off-by: Max Wolfs <[email protected]>

* implement optional animation in frontmatter

Signed-off-by: Max Wolfs <[email protected]>

* add images

Signed-off-by: Max Wolfs <[email protected]>

* add social links

Signed-off-by: Max Wolfs <[email protected]>

* add content

Signed-off-by: Max Wolfs <[email protected]>

* remove legacy logo

Signed-off-by: Max Wolfs <[email protected]>

---------

Signed-off-by: Max Wolfs <[email protected]>
  • Loading branch information
maxwolfs authored Dec 5, 2024
1 parent 9d463a2 commit 2309128
Show file tree
Hide file tree
Showing 72 changed files with 5,794 additions and 2,927 deletions.
Binary file removed .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
.cache/
public
src/gatsby-types.d.ts
/public
/public
.DS_Store
4 changes: 2 additions & 2 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const config: GatsbyConfig = {
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: './src/images/',
path: `${__dirname}/src/images/`,
},
__key: 'images',
},
Expand All @@ -64,7 +64,7 @@ const config: GatsbyConfig = {
{
matchPath: '/:lang?/index', // Match the root path and language-specific root
getLanguageFromPath: true,
},
}
],
},
},
Expand Down
123 changes: 123 additions & 0 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import path from 'path';
import { GatsbyNode } from 'gatsby';

interface MarkdownNode {
id: string;
frontmatter: {
template: string; // staticPage, post
slug: string;
language: string;
postType?: string; // announcements, event, blog
};
}

interface GraphQLResult {
data?: {
allMarkdownRemark: {
nodes: MarkdownNode[];
};
};
errors?: any;
}

export const createPages: GatsbyNode['createPages'] = async ({
graphql,
actions,
}) => {
const { createPage } = actions;

const result: GraphQLResult = await graphql(`
query FetchAllMarkdownData {
allMarkdownRemark {
nodes {
id
frontmatter {
template
slug
language
postType
}
}
}
}
`);

if (result.errors) {
throw new Error('Error loading Markdown files: ' + result.errors);
}

const items = result.data?.allMarkdownRemark.nodes;

if (!items || items.length === 0) {
console.warn('No Markdown files found.');
return;
}

items.forEach((node) => {
const { template, slug, language, postType } = node.frontmatter;

console.log(`Processing node: ${JSON.stringify(node.frontmatter)}`);

let templatePath: string;

switch (template) {
case 'staticPage':
templatePath = path.resolve('./src/templates/staticPage.tsx');
break;
case 'post':
if (!postType) {
console.warn(`Post missing postType: ${slug}`);
return;
}
templatePath = path.resolve(
`./src/templates/${postType}Post.tsx`
);
break;
default:
console.warn(`Unknown template: ${template} for ${slug}`);
return;
}

const pagePath =
template === 'post' ? `/${postType}/${slug}` : `/${slug}`

createPage({
path: pagePath,
component: templatePath,
context: {
id: node.id,
language,
slug,
},
});

console.log(`Created page: ${pagePath} with template: ${templatePath}`);
});
};

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

createTypes(`
type MarkdownRemark implements Node {
frontmatter: Frontmatter
}
type Frontmatter {
title: String
date: Date @dateformat
language: String
template: String
slug: String
postType: String
featuredImage: File @fileByRelativePath
authors: [Author]
}
type Author {
name: String
image: File @fileByRelativePath
}
`);
};
Loading

0 comments on commit 2309128

Please sign in to comment.