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.
- Code highlighting settings exist in
code.ts. To add more languages, add more settings there. That's for the little language tab that appears at the top left of code blocks.
- MDX
- Fully customizable through the usage of Gatsby Themes (and Theme UI)
- Light Mode / Dark Mode
- Typography driven, minimal style
- Tags/Categories support
- Code highlighting with prism-react-renderer and react-live support. Also allows adding line numbers, line highlighting, language tabs, and file titles.
- RSS Feed for blog posts
- Google Analytics Support
- SEO (Sitemap, OpenGraph tags, Twitter tags)
- Offline Support & WebApp Manifest
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 [email protected]:kylebarron/kylebarron.github.io.git
cd kylebarron.github.io
# install dependencies
yarn
# start hot-reloading server
gatsby developAfter 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.
```jsx:title=your-title
// code goes here
```
Or without a specific language:
```:title=your-title
// code goes here
```
Line highlighting:
You can highlight single or multiple (or both) lines in a code block. You need to add a language.
```js {2,4-5}
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.
```noLineNumbers
// code goes here
```
react-live:
Add react-live to the code block (and render the component) to see a preview below it.
```js react-live
const onClick = () => {
alert("You opened me");
};
render(<button onClick={onClick}>Alohomora!</button>);
```
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:
- Create a new folder inside
content/posts - Create a new
index.mdxfile, and add the frontmatter - Add images to the created folder (from step 1) you want to reference in your blog post
- Reference an image as your
bannerin the frontmatter - Write your content below the frontmatter
Frontmatter reference:
---
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:
- Create a new folder inside
content/pages - Create a new
index.mdxfile, and add the frontmatter - Write your content below the frontmatter
- Optionally add files/images to the folder you want to reference from the page
Frontmatter 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.
The static folder contains the icons, social media images and robots.txt. Don't forget to change these files, too!
The old Jekyll-based <kylebarron.github.io> is on the Jekyll branch.