Skip to content

Start rewriting as an elm-pages project #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ node_modules
package-lock\.json

visual-regression-screenshots
elm-stuff/
dist/
.cache/
gen/
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
loglevel=warn
save-exact=true
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# olavihaapala.fi
# elm-pages-starter

[![license](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com./olpeh/olpeh.github.io/blob/master/LICENSE)
[![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100)](https://github.com./olpeh/olpeh.github.io)
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com./dillonkearns/elm-pages-starter)

A blazing fast personal blog about development: [olavihaapala.fi](https://olavihaapala.fi).
This is an example repo to get you up and running with `elm-pages`.

Read about [how I set up my blog](https://olavihaapala.fi/2017/11/19/hello-world.html).
The entrypoint file is `index.js`. That file imports `src/Main.elm`. The `content` folder is turned into your static pages. The rest is mostly determined by logic in the Elm code! Learn more with the resources below.

Read about [how I made my blog blazing fast](https://olavihaapala.fi/2019/02/19/how-i-made-my-blog-blazing-fast.html).
## Setup Instructions

![4 times 100 in the lighthouse audit.](/images/08-blazing-fast/100.png)
Click "Use this template" on this Github page to fork the repo.

Site setup inspired by [elmtown.audio](https://github.com./elmtown/elmtown.github.io)
Or git clone it:

## Running the site locally
```
git clone [email protected]:dillonkearns/elm-pages-starter.git
```

1. Install ruby, bundler and jekyll
1. Go to the project directory on the terminal
1. Run `bundle install` to install deps
1. Install npm dependencies: `yarn`
1. Run `npm run dev` to serve the site locally
Then install and run the dev server

## Testing
```
cd elm-pages-starter
npm install
npm start # starts a local dev server using `elm-pages develop`
```

Run `npm test`, which currently only runs a test against "production" version for visual regression.
The idea is to run this test before deploying changes that should not affect layout and then run it again after deploying those changes to verify that no visual regression took place.
From there you can tweak the `content` folder or change the `src/Main.elm` file.

## Learn more about `elm-pages`

- Documentation site: https://elm-pages.com
- [Elm Package docs](https://package.elm-lang.org/packages/dillonkearns/elm-pages/latest/)
- [`elm-pages` blog](https://elm-pages.com/blog)
13 changes: 13 additions & 0 deletions content/blog/draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
{
"type": "blog",
"author": "Dillon Kearns",
"title": "A Draft Blog Post",
"description": "I'm not quite ready to share this post with the world",
"image": "/images/article-covers/mountains.jpg",
"draft": true,
"published": "2019-09-21",
}
---

This blog post is a draft! Check out `Index.elm` to see how it's being skipped in the `/blog/` listing page.
19 changes: 19 additions & 0 deletions content/blog/hello.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
{
"type": "blog",
"author": "Dillon Kearns",
"title": "Hello `elm-pages`! 🚀",
"description": "Here's an intro for my blog post to get you interested in reading more...",
"image": "/images/article-covers/hello.jpg",
"published": "2019-09-21",
}
---

Welcome to my blog! It was built with `elm-pages`!


```elm
plus : number -> number -> number
plus m n =
m + n
```
4 changes: 4 additions & 0 deletions content/blog/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: elm-pages blog
type: blog-index
---
14 changes: 14 additions & 0 deletions content/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: elm-pages-starter - a simple blog starter
type: page
---

This is an example repo to get you up and running with `elm-pages`.

The entrypoint file is `index.js`. That file imports `src/Main.elm`. The `content` folder is turned into your static pages. The rest is mostly determined by logic in the Elm code! Learn more with the resources below.

## Learn more about `elm-pages`

- Documentation site: https://elm-pages.com
- [Elm Package docs](https://package.elm-lang.org/packages/dillonkearns/elm-pages/latest/)
- [`elm-pages` blog](https://elm-pages.com/blog)
59 changes: 59 additions & 0 deletions elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"type": "application",
"source-directories": [
"src",
"gen"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"avh4/elm-color": "1.0.0",
"dillonkearns/elm-pages": "4.0.0",
"dillonkearns/elm-rss": "1.0.0",
"dillonkearns/elm-sitemap": "1.0.0",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/svg": "1.0.1",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm-community/list-extra": "8.2.3",
"elm-community/result-extra": "2.3.0",
"elm-community/string-extra": "4.0.1",
"elm-explorations/markdown": "1.0.0",
"justinmimbs/date": "3.2.0",
"lukewestby/elm-string-interpolate": "1.0.4",
"mdgriffith/elm-markup": "3.0.1",
"mdgriffith/elm-ui": "1.1.5",
"noahzgordon/elm-color-extra": "1.0.2",
"rtfeldman/elm-hex": "1.0.0"
},
"indirect": {
"billstclair/elm-xml-eeue56": "1.0.1",
"dmy/elm-imf-date-time": "1.0.1",
"elm/bytes": "1.0.8",
"elm/file": "1.0.5",
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.2",
"elm-community/dict-extra": "2.4.0",
"fredcy/elm-parseint": "2.0.1",
"justinmimbs/time-extra": "1.1.0",
"lazamar/dict-parser": "1.0.2",
"mgold/elm-nonempty-list": "4.1.0",
"miniBill/elm-codec": "1.2.0",
"ryannhg/date-format": "2.3.0",
"tripokey/elm-fuzzy": "5.2.1",
"zwilias/json-decode-exploration": "6.0.0"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.2.2"
},
"indirect": {}
}
}
Binary file added images/article-covers/hello.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/article-covers/mountains.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/author/dillon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions images/elm-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon-png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions images/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import hljs from "highlight.js/lib/highlight";
import "highlight.js/styles/github.css";
import elm from 'highlight.js/lib/languages/elm';
// we're just importing the syntaxes we want from hljs
// in order to reduce our JS bundle size
// see https://bjacobel.com/2016/12/04/highlight-bundle-size/
hljs.registerLanguage('elm', elm);


import "./style.css";
// @ts-ignore
window.hljs = hljs;
const { Elm } = require("./src/Main.elm");
const pagesInit = require("elm-pages");

pagesInit({
mainElmModule: Elm.Main
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions legacy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "olpeh.github.io",
"version": "1.0.0",
"description": "Personal blog – olavihaapala.fi",
"scripts": {
"build": "bundle exec jekyll build",
"start": "bundle exec jekyll serve",
"dev": "bundle exec jekyll serve",
"deploy": "npm run build && npm run dat",
"dat": "npm run build && rimraf ~/Sites/olpeh.github.io && cp -r _site/ ~/Sites/olpeh.github.io",
"test": "mocha test/ --timeout 35000",
"format": "prettier --write '{,!(node_modules|_site|js)/**/}*.{ts,js,css,md,html}'"
},
"repository": {
"type": "git",
"url": "git+https://github.com./olpeh/olpeh.github.io.git"
},
"author": "Olavi Haapala",
"license": "MIT",
"bugs": {
"url": "https://github.com./olpeh/olpeh.github.io/issues"
},
"homepage": "https://github.com./olpeh/olpeh.github.io#readme",
"devDependencies": {
"@types/mocha": "^5.2.5",
"husky": "^1.3.1",
"lint-staged": "^8.1.3",
"prettier": "^1.16.4",
"rimraf": "^2.6.2",
"visual-regression": "^0.2.4"
},
"lint-staged": {
"linters": {
"*.{ts,js,css,md,html}": [
"prettier --write",
"git add"
]
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
publish = "./dist/"
command = "export ELM_HOME=\"$NETLIFY_CACHE_DIR/elm\" && npm run build"
43 changes: 12 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
{
"name": "olpeh.github.io",
"version": "1.0.0",
"version": "2.0.0",
"description": "Personal blog – olavihaapala.fi",
"scripts": {
"build": "bundle exec jekyll build",
"start": "bundle exec jekyll serve",
"dev": "bundle exec jekyll serve",
"deploy": "npm run build && npm run dat",
"dat": "npm run build && rimraf ~/Sites/olpeh.github.io && cp -r _site/ ~/Sites/olpeh.github.io",
"test": "mocha test/ --timeout 35000",
"format": "prettier --write '{,!(node_modules|_site|js)/**/}*.{ts,js,css,md,html}'"
},
"repository": {
"type": "git",
"url": "git+https://github.com./olpeh/olpeh.github.io.git"
"start": "elm-pages develop",
"serve": "npm run build && http-server ./dist -a localhost -p 3000 -c-1",
"build": "elm-pages build"
},
"author": "Olavi Haapala",
"license": "MIT",
"bugs": {
"url": "https://github.com./olpeh/olpeh.github.io/issues"
},
"homepage": "https://github.com./olpeh/olpeh.github.io#readme",
"devDependencies": {
"@types/mocha": "^5.2.5",
"husky": "^1.3.1",
"lint-staged": "^8.1.3",
"prettier": "^1.16.4",
"rimraf": "^2.6.2",
"visual-regression": "^0.2.4"
"dependencies": {
"elm-pages": "1.2.10",
"highlight.js": "^9.15.10",
"node-sass": "^4.12.0"
},
"lint-staged": {
"linters": {
"*.{ts,js,css,md,html}": [
"prettier --write",
"git add"
]
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
"devDependencies": {
"elm": "latest-0.19.1",
"elm-format": "^0.8.2",
"http-server": "^0.11.1"
}
}
48 changes: 48 additions & 0 deletions src/Data/Author.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module Data.Author exposing (Author, all, decoder, view)

import Element exposing (Element)
import Html.Attributes as Attr
import Json.Decode as Decode exposing (Decoder)
import List.Extra
import Pages
import Pages.ImagePath as ImagePath exposing (ImagePath)


type alias Author =
{ name : String
, avatar : ImagePath Pages.PathKey
, bio : String
}


all : List Author
all =
[ { name = "Dillon Kearns"
, avatar = Pages.images.author.dillon
, bio = "Elm developer and educator. Founder of Incremental Elm Consulting."
}
]


decoder : Decoder Author
decoder =
Decode.string
|> Decode.andThen
(\lookupName ->
case List.Extra.find (\currentAuthor -> currentAuthor.name == lookupName) all of
Just author ->
Decode.succeed author

Nothing ->
Decode.fail ("Couldn't find author with name " ++ lookupName ++ ". Options are " ++ String.join ", " (List.map .name all))
)


view : List (Element.Attribute msg) -> Author -> Element msg
view attributes author =
Element.image
(Element.width (Element.px 70)
:: Element.htmlAttribute (Attr.class "avatar")
:: attributes
)
{ src = ImagePath.toString author.avatar, description = author.name }
Loading