-
Notifications
You must be signed in to change notification settings - Fork 3
Pull Request 1: ADD mdx blog posts #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ampahwa
wants to merge
6
commits into
AnubisLMS:main
Choose a base branch
from
ampahwa:blog
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
095ab5f
Set up gastby-node and test md
ampahwa 10bdd6a
cleaned up + added date and description to frontmatter and queries
austinbarron e98e7dc
changed 'path' to 'slug', removed extra markdown, deconstructed title…
austinbarron 6d82564
new blogpost markdown, removed unnecessary code from blog
austinbarron 62cc16a
ADD minor syling
ampahwa 1c1b80b
RM yarn.lock
ampahwa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +2,4 @@ | |
| .cache | ||
| .idea | ||
| public | ||
| yarn.lock | ||
This file contains hidden or 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,8 @@ | ||
| --- | ||
| slug: "/helloworld" | ||
| title: "Hello World" | ||
| date: "02/25/2022" | ||
| description: "Hello Description" | ||
| --- | ||
|
|
||
| Hello-World! |
This file contains hidden or 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,8 @@ | ||
| --- | ||
| slug: "/secondpost" | ||
| title: "The Second Post" | ||
| date: "02/28/2022" | ||
| description: "Second Post Description" | ||
| --- | ||
|
|
||
| Another post? |
This file contains hidden or 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 hidden or 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,45 @@ | ||
| const path = require("path") | ||
|
|
||
| // Implement the Gatsby API “createPages”. This is called once the | ||
| // data layer is bootstrapped to let plugins create pages from data. | ||
| exports.createPages = async ({ graphql, actions, reporter }) => { | ||
| const { createPage } = actions | ||
| // Query for markdown nodes to use in creating pages. | ||
| const result = await graphql( | ||
| ` | ||
| { | ||
| allMarkdownRemark(limit: 1000) { | ||
| edges { | ||
| node { | ||
| frontmatter { | ||
| slug | ||
| title | ||
| date | ||
| description | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ` | ||
| ) | ||
| // Handle errors | ||
| if (result.errors) { | ||
| reporter.panicOnBuild(`Error while running GraphQL query.`) | ||
| return | ||
| } | ||
| // Create pages for each markdown file. | ||
| const blogPostTemplate = path.resolve(`src/templates/blog-post.js`) | ||
| result.data.allMarkdownRemark.edges.forEach(({ node }) => { | ||
| const path = `/blog/${node.frontmatter.slug}` | ||
| createPage({ | ||
| path, | ||
| component: blogPostTemplate, | ||
| // In your blog post template's graphql query, you can use pagePath | ||
| // as a GraphQL variable to query for data from the markdown file. | ||
| context: { | ||
| pagePath: path, | ||
| }, | ||
| }) | ||
| }) | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,27 +1,61 @@ | ||
| import React from 'react'; | ||
| import Layout from '../components/Layout'; | ||
| import { Link, graphql } from "gatsby" | ||
|
|
||
| const Blog = () => { | ||
| const BlogPost = () => { | ||
| return ( | ||
| <div> | ||
| const Blog = ({ data }) => { | ||
| const posts = data.allMarkdownRemark.nodes | ||
|
|
||
| </div> | ||
| if (posts.length === 0) { | ||
| return ( | ||
| <Layout> | ||
| <p> | ||
| Sorry, no blogs to be found! | ||
| </p> | ||
| </Layout> | ||
| ) | ||
| } | ||
|
|
||
| return ( | ||
| <Layout> | ||
| <div className='w-max'> | ||
| <div className='space-y-3 mt-52'> | ||
| <h1 className='text-4xl font-semibold'>Anubis<span className='text-primary'> Blog</span> </h1> | ||
| <p className='text-xl text-gray'>A collection of posts by our developers and maintainers.</p> | ||
| </div> | ||
| <div className='flex flex-col items-center'> | ||
| <div/> | ||
| </div> | ||
| <div className='flex flex-col items-center'> | ||
| {posts.map(post => { | ||
| const {title, date, description} = post.frontmatter | ||
| return ( | ||
| <div className='w-max mt-16'> | ||
| <h2 className='text-4xl font-bold text-primary'> | ||
| <Link to={`blog/${post.frontmatter.slug}`} itemProp="url"> | ||
| <span itemProp="headline">{title}</span> | ||
| </Link> | ||
| </h2> | ||
| <span itemProp="date" className='text-gray'>{date}</span> | ||
| <p itemProp="description" className='text-xl text-gray'>{description}</p> | ||
| </div> | ||
| ) | ||
| })} | ||
| </div> | ||
| </div> | ||
| </Layout> | ||
| ) | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| export default Blog; | ||
| export default Blog; | ||
| export const pageQuery = graphql` | ||
| query MyQuery { | ||
| allMarkdownRemark { | ||
| nodes { | ||
| rawMarkdownBody | ||
| frontmatter { | ||
| slug | ||
| title | ||
| date | ||
| description | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ` | ||
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.