This is the Github repository for my website, kylebarron.github.io/kylebarron.dev.
I use GatsbyJS as the static site generator, because it allows for doing lots of cool things in the future, like interweaving React and Markdown with MDX.
This site started from the gatsby-starter-minimal-blog
starter, which implements the
@lekoarts/gatsby-theme-minimal-blog
Gatsby theme. This means that the default style can be overridden bit by bit by
shadowing (overwriting) individual files from the theme.
Note: The central branch for development is source not master, because
Github will only build a top-level user page from the master
branch, and won't
let me build it from the gh-pages
branch. So I use source
in place of
master
, and master
in place of gh-pages
. Travis CI builds the site to
master
automatically. Any pull request should be taken towards the source
branch.
Fork the repository, then clone it
git clone git@github.com:kylebarron/kylebarron.github.io.git
cd kylebarron.github.io
# install dependencies
yarn
# start hot-reloading server
gatsby develop
After gatsby develop
, the site is now running by default on http://localhost:8000
.
The base theme is installed as an NPM dependency. To overwrite parts of the theme, you use Gatsby shadowing (Guide: Shadowing in Gatsby Themes).
To overwrite parts of the theme, add files in this repository at
src/@lekoarts/gatsby-theme-minimal-blog/
that take effect instead of the default files from the theme.
So for example, to replace the "hero" text that shows up at the front of the homepage, add the file:
src/@lekoarts/gatsby-theme-minimal-blog/texts/hero.mdx
overriding the original hero.mdx file from the theme.
The Theme UI config can be configured by shadowing its files in src/gatsby-plugin-theme-ui/
.
Since the underlying theme ships with prism-react-renderer and react-live certain additional features were added to code blocks. You can find an overview / usage example in the example repository! If you want to change certain code styles or add additional language tabs, you need to shadow the file src/@lekoarts/gatsby-theme-minimal-blog/styles/code.js
.
Language tabs:
When you add a language (such as e.g. js
or javascript
) to the code block, a little tab will appear at the top left corner.
```js
// code goes here
**Code titles:**
You can display a title (e.g. the file path) above the code block.
// code goes here
Or without a specific language:
// code goes here
**Line highlighting:**
You can highlight single or multiple (or both) lines in a code block. You need to add a language.
const test = 3
const foo = 'bar'
const harry = 'potter'
const hermione = 'granger'
const ron = 'weasley'
**Hide line numbers:**
If you want to hide line numbers you can either globally disable them (see Theme options) or on a block-by-block basis. You can also combine that with the other attributes.
// code goes here
**react-live:**
Add `react-live` to the code block (and render the component) to see a preview below it.
const onClick = () => {
alert("You opened me");
};
render(<button onClick={onClick}>Alohomora!</button>);
### Adding content
#### Adding a new blog post
New blog posts will be shown on the index page (the three most recent ones) of this theme and on the blog overview page. They can be added by creating MDX files inside `content/posts`. General setup:
1. Create a new folder inside `content/posts`
1. Create a new `index.mdx` file, and add the frontmatter
1. Add images to the created folder (from step 1) you want to reference in your blog post
1. Reference an image as your `banner` in the frontmatter
1. Write your content below the frontmatter
**Frontmatter reference:**
```md
---
title: Introduction to "Defence against the Dark Arts"
date: 2019-11-07
description: Defence Against the Dark Arts (abbreviated as DADA) is a subject taught at Hogwarts School of Witchcraft and Wizardry and Ilvermorny School of Witchcraft and Wizardry.
tags:
- Tutorial
- Dark Arts
banner: ./defence-against-the-dark-arts.jpg
---
The fields description
and banner
are optional! If no description is provided, an excerpt of the blog post will be used. If no banner is provided, the default siteImage
(from siteMetadata
) is used.
The date
field has to be written in the format YYYY-MM-DD
!
Additional pages can be created by placing MDX files inside contents/pages
, e.g. an "About" or "Contact" page. You'll manually need to link to those pages, for example by adding them to the navigation (in navigation
option of the theme). General instructions:
content/pages
index.mdx
file, and add the frontmatterFrontmatter reference:
---
title: About
slug: "/about"
---
To edit the hero text ("Hi, I'm Lupin...), create a file at src/@lekoarts/gatsby-theme-minimal-blog/texts/hero.mdx
to edit the text.
To edit the projects part below "Latest posts", create a file at src/@lekoarts/gatsby-theme-minimal-blog/texts/bottom.mdx
to edit the contents.
static
folderThe static
folder contains the icons, social media images and robots.txt. Don't forget to change these files, too!
The old Jekyll-based