Skip to content

Galleon

Readme

Galleon Banner

Galleon is a Gatsby theme built on top of @lekoarts/gatsby-theme-minimal-blog. Use Galleon to quickly build a gorgeous developer blog with support for Typescript, MDX, syntax-highlighted code blocks, and tags.

Install the Galleon Theme

  1. Add the theme as a dependency to your Gatsby site.
1npm i --save @shetharp/gatsby-theme-galleon
2# or
3yarn add @shetharp/gatsby-theme-galleon
  1. Add the theme to your gatsby-config.js file
gatsby-config.js
1module.exports = {
2 plugins: ["@shetharp/gatsby-theme-galleon"],
3};
  1. Modify the theme options and site metadata in your gatsby-config.js file.

  2. Create .mdx files for your site's pages or posts.

  3. Shadow, override, and customize the theme to fit your needs.


Start with the Galleon Workspace

To start developing your own theme using this repo as a starting point:

1gatsby new gatsby-theme-custom https://github.com/shetharp/gatsby-theme-galleon
2cd gatsby-theme-custom
3yarn
4yarn workspace demo develop

Replace gatsby-theme-custom with whatever you wish to name your theme.

The theme workspace directory contains the components, styles, and theme configurations.

  • You should update the package.json to match the details for your theme (such as name, author, repository, etc.)
  • This workspace can be used to publish your theme as its own npm package

The demo workspace directory contains the content, components, and styles for an example site that consumes the theme.

  • You should update the package.json to include your theme as a dependency. Make sure the name of the dependency matches the name in your theme's package.json file!
  • You should then update the gatsby-config.js to include your theme as a plugin
  • This workspace can be used to deploy a demo site for your theme

Features

Galleon builds on top of the features provided in @lekoarts/gatsby-theme-minimal-blog.

  • MDX
  • Theme UI
  • Light mode / Dark mode
  • Typography driven, minimal style
  • Tags/Categories support
  • Syntax highlighting for code blocks with prism-react-renderer and react-live support. Also allows adding line numbers, line highlighting, language tabs, and file titles.

Code Highlighting

If you want to change certain code styles or add additional language tabs, you need to shadow the file src/@shetharp/gatsby-theme-galleon/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.

1```js
2// code goes here
3```

Code titles:

You can display a title (e.g. the file path) above the code block.

1```jsx:title=your-title
2// code goes here
3```

Or without a specific language:

1```:title=your-title
2// code goes here
3```

Line highlighting:

You can highlight single or multiple (or both) lines in a code block. You need to add a language.

1```js {2,4-5}
2const test = 3;
3const foo = "bar";
4const harry = "potter";
5const hermione = "granger";
6const ron = "weasley";
7```

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.

1```noLineNumbers
2// code goes here
3```

Shadowing

Please read the guide Shadowing in Gatsby Themes to understand how to customize the this theme! In general, you will want to place your files in src/@shetharp/gatsby-theme-galleon/ to shadow or override files.

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:

  • Create a new folder inside content/posts
  • Create a new index.mdx file, 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 banner in the frontmatter
  • Write your content below the frontmatter
  • Add a slug to the frontmatter to use a custom slug, e.g. slug: "/my-slug" (Optional)
1---
2title: Introduction to "Defence against the Dark Arts"
3date: 2019-11-07
4description: 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.
5tags:
6 - Tutorial
7 - Dark Arts
8banner: ./defence-against-the-dark-arts.jpg
9---
10
11Blog post content goes here...

📍 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!

Adding a new page

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 siteMetadata). General instructions:

  • Create a new folder inside content/pages
  • Create a new index.mdx file, and add the frontmatter
  • Write your content below the frontmatter
  • Optionally add files/images to the folder you want to reference from the page
1---
2title: About
3slug: "/about"
4---
5
6Page content goes here...

Changing homepage text

  • To edit the hero text ("Ahoy! This is Galleon a Gatsby theme...), create a file at src/@shetharp/gatsby-theme-galleon/texts/hero.mdx to shadow the text.
  • To edit the projects part below "Latest posts", create a file at src/@shetharp/gatsby-theme-galleon/texts/bottom.mdx to shadow the contents.