From 344a52c05b2100a562f2ee1daeb269d60ba2c135 Mon Sep 17 00:00:00 2001 From: Lennart Date: Sat, 16 Nov 2019 13:45:00 +0100 Subject: [PATCH] feat: Add gatsby-theme-minimal-blog (#151) * initial plop setup * initial theme and theme-core setup * more initial styles * add a lot of stuff * add code block component, make different basePath work * various fixes * add e2e tests * optimize mobile styles * add skipNav * add manifest icons * change font to ibm plex sans * optimizations * add READMEs * small fix * fix typo * add minimal-blog to www * add RSS feed --- .circleci/config.yml | 8 + cypress/e2e/minimal-blog.ts | 115 ++ examples/minimal-blog/.github/FUNDING.yml | 8 + examples/minimal-blog/.gitignore | 69 + examples/minimal-blog/LICENSE | 21 + examples/minimal-blog/README.md | 227 ++++ .../content/pages/about/index.mdx | 10 + .../curses-and-counter-courses/index.mdx | 10 + .../SpotifyPlayer.js | 55 + .../index.mdx | 163 +++ .../index.mdx | 188 +++ .../defence-against-the-dark-arts.jpg | Bin 0 -> 470592 bytes .../index.mdx | 29 + .../potions.jpg | Bin 0 -> 229586 bytes examples/minimal-blog/gatsby-config.js | 58 + examples/minimal-blog/package.json | 32 + .../static/android-chrome-192x192.png | Bin 0 -> 43281 bytes .../static/android-chrome-512x512.png | Bin 0 -> 270393 bytes .../static/apple-touch-icon-precomposed.png | Bin 0 -> 39304 bytes .../minimal-blog/static/apple-touch-icon.png | Bin 0 -> 38797 bytes examples/minimal-blog/static/banner.jpg | Bin 0 -> 479644 bytes .../minimal-blog/static/favicon-16x16.png | Bin 0 -> 1336 bytes .../minimal-blog/static/favicon-32x32.png | Bin 0 -> 2148 bytes examples/minimal-blog/static/favicon.ico | Bin 0 -> 15086 bytes examples/minimal-blog/static/robots.txt | 3 + plop-templates/theme/README.md.hbs | 30 +- .../src/components/navigation.tsx | 2 +- .../gatsby-theme-minimal-blog-core/.npmignore | 17 + .../gatsby-theme-minimal-blog-core/README.md | 64 + .../gatsby-config.js | 60 + .../gatsby-node.js | 296 +++++ .../gatsby-theme-minimal-blog-core/index.js | 1 + .../package.json | 49 + .../src/components/blog.tsx | 3 + .../src/components/homepage.tsx | 3 + .../src/components/page.tsx | 8 + .../src/components/post.tsx | 8 + .../src/components/tag.tsx | 8 + .../src/components/tags.tsx | 3 + .../src/templates/blog-query.tsx | 20 + .../src/templates/homepage-query.tsx | 20 + .../src/templates/page-query.tsx | 15 + .../src/templates/post-query.tsx | 29 + .../src/templates/tag-query.tsx | 20 + .../src/templates/tags-query.tsx | 15 + .../utils/default-options.js | 15 + themes/gatsby-theme-minimal-blog/.npmignore | 17 + themes/gatsby-theme-minimal-blog/README.md | 276 ++++ .../gatsby-config.js | 49 + themes/gatsby-theme-minimal-blog/index.js | 1 + themes/gatsby-theme-minimal-blog/package.json | 57 + .../components/blog.tsx | 15 + .../components/homepage.tsx | 15 + .../components/page.tsx | 15 + .../components/post.tsx | 15 + .../components/tag.tsx | 16 + .../components/tags.tsx | 19 + .../src/components/blog-list-item.tsx | 38 + .../src/components/blog.tsx | 42 + .../src/components/code.tsx | 113 ++ .../src/components/colormode-toggle.tsx | 78 ++ .../src/components/footer.tsx | 44 + .../src/components/header.tsx | 57 + .../src/components/homepage.tsx | 44 + .../src/components/item-tags.tsx | 31 + .../src/components/layout.tsx | 48 + .../src/components/list.tsx | 22 + .../src/components/listing.tsx | 27 + .../src/components/navigation.tsx | 28 + .../src/components/page.tsx | 31 + .../src/components/post.tsx | 65 + .../src/components/seo.tsx | 69 + .../src/components/skip-nav.tsx | 39 + .../src/components/tag.tsx | 48 + .../src/components/tags.tsx | 43 + .../src/components/title.tsx | 42 + .../src/gatsby-plugin-theme-ui/components.js | 25 + .../src/gatsby-plugin-theme-ui/index.js | 136 ++ .../src/hooks/use-navigation.tsx | 31 + .../src/hooks/use-site-metadata.tsx | 55 + .../gatsby-theme-minimal-blog/src/index.d.ts | 3 + .../src/styles/code.ts | 172 +++ .../src/texts/bottom.mdx | 4 + .../src/texts/hero.mdx | 6 + .../src/utils/newsletterFeed.js | 46 + .../src/utils/replaceSlashes.ts | 11 + www/data/minimal-blog.png | Bin 0 -> 230322 bytes www/data/themes.yaml | 12 + www/yarn.lock | 1166 +++++++++-------- yarn.lock | 179 ++- 90 files changed, 4397 insertions(+), 535 deletions(-) create mode 100644 cypress/e2e/minimal-blog.ts create mode 100644 examples/minimal-blog/.github/FUNDING.yml create mode 100644 examples/minimal-blog/.gitignore create mode 100644 examples/minimal-blog/LICENSE create mode 100644 examples/minimal-blog/README.md create mode 100644 examples/minimal-blog/content/pages/about/index.mdx create mode 100644 examples/minimal-blog/content/posts/curses-and-counter-courses/index.mdx create mode 100644 examples/minimal-blog/content/posts/fantastic-beasts-and-where-to-find-them/SpotifyPlayer.js create mode 100644 examples/minimal-blog/content/posts/fantastic-beasts-and-where-to-find-them/index.mdx create mode 100644 examples/minimal-blog/content/posts/harry-potter-and-the-half-blood-prince/index.mdx create mode 100644 examples/minimal-blog/content/posts/introduction-to-defence-against-the-dark-arts/defence-against-the-dark-arts.jpg create mode 100644 examples/minimal-blog/content/posts/introduction-to-defence-against-the-dark-arts/index.mdx create mode 100644 examples/minimal-blog/content/posts/introduction-to-defence-against-the-dark-arts/potions.jpg create mode 100644 examples/minimal-blog/gatsby-config.js create mode 100644 examples/minimal-blog/package.json create mode 100644 examples/minimal-blog/static/android-chrome-192x192.png create mode 100644 examples/minimal-blog/static/android-chrome-512x512.png create mode 100644 examples/minimal-blog/static/apple-touch-icon-precomposed.png create mode 100644 examples/minimal-blog/static/apple-touch-icon.png create mode 100644 examples/minimal-blog/static/banner.jpg create mode 100644 examples/minimal-blog/static/favicon-16x16.png create mode 100644 examples/minimal-blog/static/favicon-32x32.png create mode 100644 examples/minimal-blog/static/favicon.ico create mode 100644 examples/minimal-blog/static/robots.txt create mode 100644 themes/gatsby-theme-minimal-blog-core/.npmignore create mode 100644 themes/gatsby-theme-minimal-blog-core/README.md create mode 100644 themes/gatsby-theme-minimal-blog-core/gatsby-config.js create mode 100644 themes/gatsby-theme-minimal-blog-core/gatsby-node.js create mode 100644 themes/gatsby-theme-minimal-blog-core/index.js create mode 100644 themes/gatsby-theme-minimal-blog-core/package.json create mode 100644 themes/gatsby-theme-minimal-blog-core/src/components/blog.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/components/homepage.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/components/page.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/components/post.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/components/tag.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/components/tags.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/templates/blog-query.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/templates/homepage-query.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/templates/page-query.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/templates/post-query.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/templates/tag-query.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/src/templates/tags-query.tsx create mode 100644 themes/gatsby-theme-minimal-blog-core/utils/default-options.js create mode 100644 themes/gatsby-theme-minimal-blog/.npmignore create mode 100644 themes/gatsby-theme-minimal-blog/README.md create mode 100644 themes/gatsby-theme-minimal-blog/gatsby-config.js create mode 100644 themes/gatsby-theme-minimal-blog/index.js create mode 100644 themes/gatsby-theme-minimal-blog/package.json create mode 100644 themes/gatsby-theme-minimal-blog/src/@lekoarts/gatsby-theme-minimal-blog-core/components/blog.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/@lekoarts/gatsby-theme-minimal-blog-core/components/homepage.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/@lekoarts/gatsby-theme-minimal-blog-core/components/page.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/@lekoarts/gatsby-theme-minimal-blog-core/components/post.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/@lekoarts/gatsby-theme-minimal-blog-core/components/tag.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/@lekoarts/gatsby-theme-minimal-blog-core/components/tags.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/blog-list-item.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/blog.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/code.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/colormode-toggle.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/footer.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/header.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/homepage.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/item-tags.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/layout.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/list.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/listing.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/navigation.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/page.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/post.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/seo.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/skip-nav.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/tag.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/tags.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/components/title.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/gatsby-plugin-theme-ui/components.js create mode 100644 themes/gatsby-theme-minimal-blog/src/gatsby-plugin-theme-ui/index.js create mode 100644 themes/gatsby-theme-minimal-blog/src/hooks/use-navigation.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/hooks/use-site-metadata.tsx create mode 100644 themes/gatsby-theme-minimal-blog/src/index.d.ts create mode 100644 themes/gatsby-theme-minimal-blog/src/styles/code.ts create mode 100644 themes/gatsby-theme-minimal-blog/src/texts/bottom.mdx create mode 100644 themes/gatsby-theme-minimal-blog/src/texts/hero.mdx create mode 100644 themes/gatsby-theme-minimal-blog/src/utils/newsletterFeed.js create mode 100644 themes/gatsby-theme-minimal-blog/src/utils/replaceSlashes.ts create mode 100644 www/data/minimal-blog.png diff --git a/.circleci/config.yml b/.circleci/config.yml index d927afa96..b1a6cf883 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -132,6 +132,12 @@ jobs: - e2e-test: example-name: graphql-playground + e2e-test-minimal-blog: + <<: *e2e-executor + steps: + - e2e-test: + example-name: minimal-blog + workflows: version: 2 lint-test: @@ -148,3 +154,5 @@ workflows: <<: *e2e-test-workflow - e2e-test-graphql-playground: <<: *e2e-test-workflow + - e2e-test-minimal-blog: + <<: *e2e-test-workflow diff --git a/cypress/e2e/minimal-blog.ts b/cypress/e2e/minimal-blog.ts new file mode 100644 index 000000000..9f1d40876 --- /dev/null +++ b/cypress/e2e/minimal-blog.ts @@ -0,0 +1,115 @@ +/// +/// +/// + +describe(`gatsby-theme-minimal-blog`, () => { + beforeEach(() => { + cy.visit(`/`).waitForRouteChange() + }) + it(`should render the title`, () => { + cy.get(`h1`).within(() => { + cy.findByText(/Lupin/i) + }) + }) + it(`should link the about page`, () => { + cy.get(`nav`).within(() => { + cy.findByText(/About/i) + .click() + .waitForRouteChange() + .assertRoute(`/about`) + }) + }) + it(`should link the blog page`, () => { + cy.get(`nav`).within(() => { + cy.findByText(/Blog/i).click() + }) + cy.waitForRouteChange() + .assertRoute(`/blog`) + .get(`h2`) + .within(() => { + cy.findByText(/Blog/i) + }) + .findByText(/Fantastic Beasts and Where to Find Them/i) + .findByText(/View all tags/i) + }) + it(`should have functioning tags in list items`, () => { + cy.visit(`/blog`) + .waitForRouteChange() + .findByText(/Tutorial/i) + .click() + .waitForRouteChange() + .assertRoute(`/tags/tutorial`) + .get(`h2`) + .within(() => { + cy.findByText(/Tutorial/i) + }) + .findByText(/Introduction to "Defence against the Dark Arts"/i) + }) + it(`should have functioning tags overview page`, () => { + cy.visit(`/blog`) + .waitForRouteChange() + .findByText(/View all tags/i) + .click() + .waitForRouteChange() + .assertRoute(`/tags`) + .get(`h2`) + .within(() => { + cy.findByText(/Tags/i) + }) + .findByText(/Novel/i) + }) + it(`should have social media links`, () => { + cy.get(`header`).within(() => { + cy.findByText(/Twitter/i).should(`have.attr`, `href`, `https://twitter.com/lekoarts_de`) + }) + }) + it(`should render the hero`, () => { + cy.findByText(/Those nasty Dementors/i) + }) + it(`should render the latest posts`, () => { + cy.findByText(/Latest Posts/i) + .findByText(/Fantastic Beasts and Where to Find Them/i) + .findByText(/Read all posts/i) + }) + it(`should render the bottom part`, () => { + cy.findByText(/Projects/i) + .findByText(/Instagram Project "Proprius"/i) + .should(`have.attr`, `href`, `https://www.lekoarts.de/en/projects/private-instagram-project-proprius`) + }) + it(`should render the footer`, () => { + cy.findByLabelText(`Link to the theme's GitHub repository`) + .contains(`Theme`) + .findByLabelText(`Link to the theme author's website`) + .contains(`LekoArts`) + .findByText(/ยฉ 2019 by Lupin./i) + }) + it(`should link to individual blog post`, () => { + cy.findByText(/Introduction to "Defence against the Dark Arts"/i) + .click() + .waitForRouteChange() + .assertRoute(`/introduction-to-defence-against-the-dark-arts`) + .get(`h2`) + .within(() => { + cy.findByText(/Introduction to "Defence against the Dark Arts"/i) + }) + .findByText(/07.11.2019/i) + .findByText(/Tutorial/i) + .findByText(/2 min read/i) + .findByText( + /Thestral dirigible plums, Viktor Krum hexed memory charm Animagus Invisibility Cloak three-headed Dog./i + ) + }) + it(`should render the light/dark mode toggle`, () => { + cy.findByLabelText(/Activate Dark Mode/i) + }) + it(`should have functioning dark mode toggle`, () => { + cy.findByTestId(`theme-root`) + .should(`have.css`, `color`, `rgb(45, 55, 72)`) + .should(`have.css`, `background`, `rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box`) + .findByLabelText(/Activate Dark Mode/i) + .click() + .findByTestId(`theme-root`) + .should(`have.css`, `color`, `rgb(203, 213, 224)`) + .should(`have.css`, `background`, `rgb(26, 32, 44) none repeat scroll 0% 0% / auto padding-box border-box`) + }) +}) diff --git a/examples/minimal-blog/.github/FUNDING.yml b/examples/minimal-blog/.github/FUNDING.yml new file mode 100644 index 000000000..10a645f39 --- /dev/null +++ b/examples/minimal-blog/.github/FUNDING.yml @@ -0,0 +1,8 @@ +# These are supported funding model platforms + +github: [LekoArts] +patreon: lekoarts +open_collective: # Replace with a single Open Collective username +ko_fi: lekoarts +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +custom: # Replace with a single custom sponsorship URL \ No newline at end of file diff --git a/examples/minimal-blog/.gitignore b/examples/minimal-blog/.gitignore new file mode 100644 index 000000000..00b2c3049 --- /dev/null +++ b/examples/minimal-blog/.gitignore @@ -0,0 +1,69 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages +**/node_modules/** + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.* +!.env.example + +.cache +**/.cache +public + +.idea +.vscode +.DS_Store \ No newline at end of file diff --git a/examples/minimal-blog/LICENSE b/examples/minimal-blog/LICENSE new file mode 100644 index 000000000..f1178c776 --- /dev/null +++ b/examples/minimal-blog/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 LekoArts + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/examples/minimal-blog/README.md b/examples/minimal-blog/README.md new file mode 100644 index 000000000..8238c8160 --- /dev/null +++ b/examples/minimal-blog/README.md @@ -0,0 +1,227 @@ +

+ + LekoArts + +

+

+ Gatsby Starter: Minimal Blog +

+ +

+ + Minimal Blog is released under the MIT license. + + PRs welcome! + + Follow @lekoarts_de + + + Netlify Status + +

+ +Typography driven, feature-rich blogging theme with minimal aesthetics. Includes tags/categories support and extensive features for code blocks such as live preview, line numbers, and line highlighting. Using the Gatsby Theme [`@lekoarts/gatsby-theme-minimal-blog`](https://github.com/LekoArts/gatsby-themes/tree/master/themes/gatsby-theme-minimal-blog). + +[**Demo Website**](https://minimal-blog.lekoarts.de) + +Also be sure to checkout other [Free & Open Source Gatsby Themes](https://themes.lekoarts.de) + +## โœจ Features + +- 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](https://github.com/FormidableLabs/prism-react-renderer) and [react-live](https://github.com/FormidableLabs/react-live) support. Also allows adding line numbers, line highlighting, language tabs, and file titles. +- Google Analytics Support +- SEO (Sitemap, OpenGraph tags, Twitter tags) +- Offline Support & WebApp Manifest + +## ๐Ÿš€ Getting Started + +1. **Create a Gatsby site.** + +Use the Gatsby CLI to create a new site, specifying this project + +```sh +gatsby new project-name https://github.com/LekoArts/gatsby-starter-minimal-blog +``` + +2. **Start developing.** + +Navigate into your new site's directory and start it up. + +```sh +cd project-name +gatsby develop +``` + +3. **Open the code and start customizing!** + +Your site is now running at `http://localhost:8000`! + +If you want to learn more about how you can use a Gatsby starter that is configured with a Gatsby theme, you can checkout this [shorter](https://www.gatsbyjs.org/docs/themes/using-a-gatsby-theme/) or [longer](https://www.gatsbyjs.org/tutorial/using-a-theme/) tutorial. The tutorials don't exactly apply to this starter however the concepts are the same. + +## ๐Ÿ“ Using and modifying this starter + +**Important Note:** Please read the guide [Shadowing in Gatsby Themes](https://www.gatsbyjs.org/docs/themes/shadowing/) to understand how to customize the underlying theme! + +This starter creates a new Gatsby site that installs and configures the theme [`@lekoarts/gatsby-theme-minimal-blog`](https://github.com/LekoArts/gatsby-themes/tree/master/themes/gatsby-theme-minimal-blog). + +Have a look at the theme's README and files to see what options are available and how you can shadow the various components including Theme UI. Generally speaking you will want to place your files into `src/@lekoarts/gatsby-theme-minimal-blog/` to shadow/override files. The Theme UI config can be configured by shadowing its files in `src/gatsby-plugin-theme-ui/`. + +### Code Highlighting + +Since the underlying theme ships with [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer) and [react-live](https://github.com/FormidableLabs/react-live) certain additional features were added to code blocks. You can find an overview / usage example in the [example repository](https://github.com/LekoArts/gatsby-themes/tree/master/examples/minimal-blog/content/posts/fantastic-beasts-and-where-to-find-them/index.mdx)! 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(); +``` +```` + +### 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`! + +#### 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: + +1. Create a new folder inside `content/pages` +1. Create a new `index.mdx` file, and add the frontmatter +1. Write your content below the frontmatter +1. Optionally add files/images to the folder you want to reference from the page + +**Frontmatter reference:** + +```md +--- +title: About +slug: "/about" +--- +``` + +#### Changing the "Hero" text + +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. + +#### Changing the "Projects" part + +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. + +### Change your `static` folder + +The `static` folder contains the icons, social media images and robots.txt. Don't forget to change these files, too! + +## ๐Ÿค” Questions or problems? + +Please open up an issue on the main repository: [LekoArts/gatsby-themes](https://github.com/LekoArts/gatsby-themes). Thanks! + +## ๐ŸŽ“ Learning Gatsby + +Looking for more guidance? Full documentation for Gatsby lives [on Gatsby's website](https://www.gatsbyjs.org/). + +### Themes + +- To learn more about Gatsby themes specifically, we recommend checking out the [theme docs](https://www.gatsbyjs.org/docs/themes/). + +### General + +- **For most developers, I recommend starting with the [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process. + +- **To dive straight into code samples, head [to Gatsby's documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Reference Guides_ and _Gatsby API_ sections in the sidebar. + +## ๐ŸŒŸ Supporting me + +Thanks for using this project! I'm always interested in seeing what people do with my projects, so don't hesitate to tag me on [Twitter](https://twitter.com/lekoarts_de) and share the project with me. + +Please star this project, share it on Social Media or consider supporting me on [Patreon](https://www.patreon.com/lekoarts)! + +If you want to hire me for **contract/freelance work**, you can do so! [Get in touch with me!](https://www.lekoarts.de/en/contact) diff --git a/examples/minimal-blog/content/pages/about/index.mdx b/examples/minimal-blog/content/pages/about/index.mdx new file mode 100644 index 000000000..ee4a88277 --- /dev/null +++ b/examples/minimal-blog/content/pages/about/index.mdx @@ -0,0 +1,10 @@ +--- +title: About +slug: "/about" +--- + +Hi! + +Remus Lupin - also known as Moony - is currently teaching "Defense against the Dark Arts" at Hogwarts. He was afflicted with lycanthropy during his childhood, as a result of Fenrir Greyback's revenge against Lyall. He attended Hogwarts School of Witchcraft and Wizardry from 1971-1978 and was Sorted into Gryffindor House. During his school years he was one of the Marauders, best friends with Sirius Black, James Potter, and Peter Pettigrew. Together they created the Marauder's Map. + +He fought against Death Eaters once more in the Second Wizarding War, during which he lost his friend Sirius. In 1997, Remus married fellow Order member Nymphadora Tonks and had a son, Edward Remus Lupin, of whom he named Harry the godfather. Remus fought at the Battle of Hogwarts on 2 May, 1998, during which his wife was murdered by Bellatrix Lestrange. Remus was also murdered by Death Eater, Antonin Dolohov, during the first half of the same battle. His death was avenged by Filius Flitwick. diff --git a/examples/minimal-blog/content/posts/curses-and-counter-courses/index.mdx b/examples/minimal-blog/content/posts/curses-and-counter-courses/index.mdx new file mode 100644 index 000000000..fabd246ca --- /dev/null +++ b/examples/minimal-blog/content/posts/curses-and-counter-courses/index.mdx @@ -0,0 +1,10 @@ +--- +title: "Curses and Counter-curses (Bewitch Your Friends and Befuddle Your Enemies with the Latest Revenges: Hair Loss, Jelly-Legs, Tongue-Tying, and Much, Much More)" +date: 2019-10-25 +--- + +Thestral dirigible plums, Viktor Krum hexed memory charm Animagus Invisibility Cloak three-headed Dog. Half-Blood Prince Invisibility Cloak cauldron cakes, hiya Harry! Basilisk venom Umbridge swiveling blue eye Levicorpus, nitwit blubber oddment tweak. Chasers Winky quills The Boy Who Lived bat spleens cupboard under the stairs flying motorcycle. Sirius Black Holyhead Harpies, youโ€™ve got dirt on your nose. Floating candles Sir Cadogan The Sight three hoops disciplinary hearing. Grindlewald pigโ€™s tail Sorcerer's Stone biting teacup. Side-along dragon-scale suits Filch 20 points, Mr. Potter. + +> Mobilicorpus reducto liberacorpus crucio. Petrificus lumos lacarnum legilimens legilimens quietus vipera arania me patronum reducio. Episkey reducio quietus mobilicorpus fidelius aparecium. Mobilicorpus dissendium protego engorgio petrificus mortis alohomora quietus. + +Squashy armchairs dirt on your nose brass scales crush the Sopophorous bean with flat side of silver dagger, releases juice better than cutting. Full moon Whomping Willow three turns should do it lemon drops. Locomotor trunks owl treats that will be 50 points, Mr. Potter. Witch Weekly, he will rise again and he will come for us, headmaster Erumpent horn. Fenrir Grayback horseless carriages โ€˜zis is a chance many would die for! diff --git a/examples/minimal-blog/content/posts/fantastic-beasts-and-where-to-find-them/SpotifyPlayer.js b/examples/minimal-blog/content/posts/fantastic-beasts-and-where-to-find-them/SpotifyPlayer.js new file mode 100644 index 000000000..aae06126c --- /dev/null +++ b/examples/minimal-blog/content/posts/fantastic-beasts-and-where-to-find-them/SpotifyPlayer.js @@ -0,0 +1,55 @@ +/* eslint react/no-unknown-property: 0 */ +/* eslint react/prefer-stateless-function: 0 */ + +/** + * Spotify player iframe widget + * + * @author Alexander Wallin + * @see https://developer.spotify.com/technologies/widgets/spotify-play-button/ + */ + +import React, { Component } from "react" + +// Size presets, defined by Spotify +const sizePresets = { + large: { + width: 300, + height: 380, + }, + compact: { + width: 300, + height: 80, + }, +} + +/** + * SpotifyPlayer class + */ +class SpotifyPlayer extends Component { + // ------------------------------------------------------ + // Render + // ------------------------------------------------------ + + render() { + const { uri, view, theme } = this.props + let { size } = this.props + + if (typeof size === `string`) { + size = sizePresets[size] + } + + return ( +