-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pages, animation, content and improve overall layout (#4)
* 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
Showing
72 changed files
with
5,794 additions
and
2,927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules/ | |
.cache/ | ||
public | ||
src/gatsby-types.d.ts | ||
/public | ||
/public | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
`); | ||
}; |
Oops, something went wrong.