• This repository has been archived on 12/Feb/2023
  • Stars
    star
    470
  • Rank 93,030 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Gatsby theme for publishing code-related notes to your website

Warning This work on this project is now archived. I have created an up-to-date version of this using Eleventy and the source code for it can be found here. If anyone would like to continue work on this theme, please let me know.

Features

  • Notes can:
    • be written using Markdown (.md) or MDX (.mdx)
    • have zero, one or many tags. See an example here
    • have associated emojis 👏
    • be nested in subfolders so you can organise them how you like
    • sketchy annotations (highlights, strike-thoughs etc). Find out more here
  • Extra markdown features have also been added. Find out more here
  • Note search powered by the super-fast Flexsearch

Installation

mkdir my-site
cd my-site
yarn init

# install gatsby-theme-code-notes and it's dependencies
yarn add gatsby-theme-code-notes gatsby react react-dom

# or

npm install gatsby-theme-code-notes gatsby react react-dom

Using the Gatsby starter

Step 1: Starter installation

Source code for the starter can be found at: https://github.com/MrMartineau/gatsby-starter-code-notes

With gatsby-cli:
gatsby new code-notes https://github.com/MrMartineau/gatsby-starter-code-notes
With git clone:
git clone [email protected]:MrMartineau/gatsby-starter-code-notes.git

cd code-notes

yarn

Step 2: Develop & Build

Once installed or cloned locally and all packages are installed you can begin developing your site.

# Run localhost
yarn dev

# Build your Gatsby site
yarn build

Usage

Theme Options

Key Default value Description
basePath / Root url for all notes pages
contentPath /content/notes Location of notes content
logo '' (empty string) Path to your site's logo. Will be used as the src attribute for an image
showDescriptionInSidebar true Show config.site.description in the sidebar
showDate false Show the note's modified date
gitRepoContentPath '' Set the location for your notes if they're hosted online, e.g. your git repo. This will show a "Edit this page" link underneath each note
showThemeInfo true Show info about this Gatsby theme
mdxOtherwiseConfigured true Configure gatsby-plugin-mdx. Note that most sites will not need to use this flag. If your site has already configured gatsby-plugin-mdx separately, set this flag false.
flexSearchEngineOptions { encode: 'icase', tokenize: 'forward', resolution: 9 } Configure FlexSearch's index method. The default value uses FlexSearch's default preset. Find out your other options here.
openSearch { } Configure the opensearch.xml file contents. This file is generated during the build process. If you want to add opensearch support, ensure you set a siteUrl in the config. See below for more information.

Example usage

This example overrides some of the theme defaults and shows the various options for the opensearch config.

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-theme-code-notes`,
      options: {
        basePath: '/',
        contentPath: '/content/notes',
        gitRepoContentPath:
          'https://github.com/mrmartineau/gatsby-theme-code-notes/tree/master/example/code-notes/',
        showDescriptionInSidebar: true,
        showThemeInfo: false,
        logo: 'https://brand.zander.wtf/Avatar.png',
        showDate: true,

        // Opensearch is used to enhance the search on your site.
        // If you want to add it, ensure you set a `siteUrl`
        openSearch: {
          siteUrl: 'https://code-notes-example.netlify.app', // required if you want opensearch
          siteShortName: 'Gatsby Theme Code Notes Example', // override the default value of 'Search`
          siteTags: 'front-end', // optional
          siteContact: 'https://twitter.com/MrMartineau', // optional
          siteDescription: 'A Gatsby theme for storing your code-related notes', // optional
        },
      },
    },
  ],
}

Add notes to your site by creating md or mdx files inside /content/notes.

Note that if you've changed the default contentPath in the configuration, you'll want to add your markdown files in the directory specified by that path.

Note frontmatter

Frontmatter information (written in YAML) can be used to add metadata and extra information for your notes

Only the title field is required, the rest are optional.

---
title: Note metadata
emoji: 😃
tags:
  - metadata
  - info
link: https://zander.wtf
---

Link

The link item is used to display a link that is related to the note itself. It will appear below the title if.

Emoji

The emoji frontmatter item will add an emoji beside the title on listing views and above the title on individual note pages

Tags

The tags array frontmatter item allows you to add as many tags to a note as you'd like.

Dates

The modified frontmatter item allows you set a date for your note. This means they can then be sorted (ascending & descending) when viewed in the note list pages. This was introduced in v2.0.0.

The created frontmatter item works in a similar way, but it is not being used at the moment so it can be ommitted.

1. Add new modified key to your YAML frontmatter

This will mean that you have to update all your notes with a timestamp.

---
title: Storybook
tags:
  - testing
emoji: 📖
link: 'https://storybook.js.org'
created: 2020-02-27T23:02:00.000Z # this is not used by the theme at the moment
modified: 2021-01-16T10:31:32.000Z

# any valid ISO timestamp should work, like this:
# modified: 2021-01-16
---

If you have many notes and want to speed up adding all those timestamps, I created an npm package (frontmatter-date-setter) to automate it based on your last git or file modification dates.

Use the frontmatter-date-setter (or fds) CLI like so: (where notes is the directory of all your notes)

fds --directory=notes --debug

The package does have a few issues that I'd like to improve. For example, it will convert most emojis to unicode strings, and will format other parts of your frontmatter. So take care when you run it.

2. Set showDate: true in gatsby-config.js

Setting this value in this plugin's config renders the interface to switch to date sorting as well as showing the date in other parts of the interface.

Advanced usage

PWA

Turn your code notes into a PWA using this extra config. This requires gatsby-plugin-manifest and gatsby-plugin-offline.

// gatsby-config.js
{
  resolve: `gatsby-plugin-manifest`,
  options: {
    name: `Zander's Code Notes`,
    short_name: `CodeNotes`,
    description: `Notes on code. My memory bank.`,
    start_url: `/`,
    background_color: `hsl(210, 38%, 95%)`,
    theme_color: `hsl(345, 100%, 69%)`,
    display: `standalone`,
    icon: `static/logo.png`,
    showDate: true,
  },
},
{
  resolve: `gatsby-plugin-offline`,
  options: {
    precachePages: [`/*`, `/tag/*`],
  },
},

License

MIT © Zander Martineau

Made by Zander • zander.wtfGitHubTwitter

More Repositories

1

design-system-utils

👩‍🎨 Access your design tokens with ease
TypeScript
537
star
2

SublimeTextSetupWiki

Enable people to get started with Sublime Text 2 much more quickly
JavaScript
463
star
3

awesome-web-dev-resources

👌 My collection of go-to web development resources
224
star
4

Placeholders

Placeholder HTML & content (lorem ipsum) package for Sublime Text 2
143
star
5

trak.js

Universal analytics event tracking API
JavaScript
134
star
6

HTML5-Coda-Clips

A selection of HTML5 snippets for use in Panic's Coda web dev app
87
star
7

SimpleSharing

Twitter, Facebook, Google+, Instapaper & LinkedIn social link that do not rely on Javascript
CSS
56
star
8

webpack-recipes

🆘 A collection of webpack configurations
JavaScript
48
star
9

Otter

Otter is a self-hosted bookmark manager made with Next.js and Supabase with Mastodon integration.
TypeScript
47
star
10

react-design-system-boilerplate

At the moment this project is out-of-date and unmaintained. I hope to revisit it soon though... This is a boilerplate for you to create your own design system in React. It has everything setup to allow you to focus on what it is you care about: creating awesome, reusable components.
TypeScript
46
star
11

SublimeText3UserSettings

My personal Sublime Text 3 User Settings
43
star
12

notes.zander.wtf-gatsby

Notes on code. My memory bank.
TypeScript
40
star
13

Boost

Boost is now Kickoff, see adjacent link
CSS
38
star
14

xkcd-api

💪 CORS enabled version of the XKCD API
JavaScript
37
star
15

stitches-ui

A minimal implementation of Theme UI using Stitches
TypeScript
25
star
16

scriptable-widgets

JavaScript
24
star
17

snippet-generator

⚡ Sublime Text, Atom & VS Code snippet generator
JavaScript
24
star
18

ZM-Resources

List of all scripts & resources I use on a regular basis
23
star
19

Coda-Blackboard-Seestyles

Syntax highlighting themes for Coda
18
star
20

gatsby-starter-code-notes

JavaScript
17
star
21

prismic-reactjs-custom

This is an opinionated fork of prismic-reactjs that allows you to use custom React components instead of standard HTML tags
TypeScript
15
star
22

depdoc

Auto-generate markdown documentation using your package.json's dependencies
JavaScript
13
star
23

Choreographic-Grid

Not ready for prime-time yet, but I hope this could help solve lots of responsive content choreography problems
CSS
13
star
24

pinboard-chrome-extension

This Chrome extension improves the design and UX of Pinboard.in
CSS
12
star
25

zander.wtf-2020

👱 My personal website
CSS
11
star
26

SublimeText2UserSettings

My personal Sublime Text 2 User Settings
Ruby
11
star
27

SASS-Snippets

A collection of Sublime Text 2 snippets & functions to be used with SASS. Most snippets are to be used specifically with .scss
8
star
28

cloudflare-worker-scraper

Page Metadata Scraper with Cloudflare workers
TypeScript
7
star
29

notes.zander.wtf

TILs, snippets—my digital code garden 🌱
CSS
7
star
30

cloze-test

Simple Cloze test generator
JavaScript
6
star
31

zander.wtf-2019

👱 My personal website
JavaScript
6
star
32

Sketch-website-template

Responsive website design template for Sketch 3
6
star
33

pinboard-api

A free, CORS-enabled version of the Pinboard public feeds API
JavaScript
5
star
34

feeds.zander.wtf-svelte

My feeds, built with Svelte, Tailwind, Vite
Svelte
4
star
35

frontmatter-date-setter

JavaScript
4
star
36

alfred-npm-versions

Lookup the latest 15 versions for an npm package
JavaScript
4
star
37

zander.wtf-2017

My old personal portfolio and blog
CSS
4
star
38

programmers-clipboard

👌 Copy unicode characters to your clipboard for use in different programming languages: CSS, Javascript, HTML & plain text
JavaScript
4
star
39

refined-prismic

Browser extension that simplifies the Prismic interface and adds useful features
JavaScript
3
star
40

the-unit

Parses a number and unit string, and returns the unit used
JavaScript
3
star
41

react-npm-package

A base for an npm package that uses React, Vite, Storybook and Vitest
TypeScript
3
star
42

feeds.zander.wtf-nextjs

TypeScript
3
star
43

pinboard-api-cache

A free, CORS-enabled version of the Pinboard public feeds API, but with a one hour cache
JavaScript
3
star
44

rigel-vscode

Port of Rigel theme for VS Code
3
star
45

InteractionCheck.js

Prompt users if they have not interacted with your page for a given amount of time
JavaScript
3
star
46

front-end-vscode-extensionpack

A collection of extensions for working with Front-end Applications in VS Code
3
star
47

fish

My fish shell dotfiles
Shell
2
star
48

scrollObserver

Add class to element when a specific scroll value has been reached
JavaScript
2
star
49

isDateValid

Validate a date
TypeScript
2
star
50

zander.wtf

my site
XSLT
1
star
51

journal

A personal journalling app built with SvelteKit, Supabase & little bit of AI
Svelte
1
star
52

gh-release-experiments

1
star
53

coding-standards

Coding standards and resources
1
star
54

Stacey-Bundle

Textmate bundle for the brilliant Stacey CMS (http://staceyapp.com/)
1
star
55

social-homepage

My social homepage, MrMartineau.co.uk.
CSS
1
star
56

githubwatched

Simple app to show a user's watched & owned repos
JavaScript
1
star
57

zander-react-contentful

JavaScript
1
star
58

issue-templates

1
star
59

HTMLPrototype

My basis for HTML/PHP prototypes
JavaScript
1
star
60

mrmartineau

1
star
61

zander.wtf-after.js

experimental after.js version of my next.js website
JavaScript
1
star
62

gitmoji-alfred-snippets

Gitmoji snippets for Alfred
1
star
63

scripts

Shareable config scripts
JavaScript
1
star
64

grunt-filesizegzip

Grunt plugin to output file size information
JavaScript
1
star
65

raycast-extensions

TypeScript
1
star
66

rollup-routes-test

JavaScript
1
star
67

unsplash-search

Simple Unsplash search
JavaScript
1
star
68

CSSOff2013

My submission for the 2013 CSSOff competition. Unfortunately I was not able to finish due to lack of available time
CSS
1
star
69

rsstojson

Simple API to convert RSS feeds to JSON
TypeScript
1
star
70

KOglossaryLinks

KOglossaryLinks is a jQuery plugin that shows tooltips of glossary terms, from a JSON feed, when hovered (or tapped on touchscreen devices)
CSS
1
star
71

Boost-Snippets

Sublime Text 2 package for my Boost front-end framework
1
star