Skip to content

Commit

Permalink
chore: format files
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Feb 1, 2025
1 parent d3d92dc commit e6d7164
Show file tree
Hide file tree
Showing 47 changed files with 1,740 additions and 1,248 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
elm*.json
docs.json
review/suppressed/
12 changes: 6 additions & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"endOfLine": "lf",
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
"endOfLine": "lf",
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
8 changes: 4 additions & 4 deletions CHANGELOG-ELM.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]

### Changed

- Updated version constraint so users now need to use "mdgriffith/elm-codegen": "5.0.0 <= v < 6.0.0" (be sure to update your `scripts/elm.json` as well!)

## [10.2.0] - 2024-12-12
Expand All @@ -28,11 +29,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `BackendTask.Glob.fromString` and `BackendTask.Glob.fromStringWithOptions` allow capturing matching file paths directly from a string pattern. Useful for use with executing shell commands since there is no glob expansion in the command API.
- `Pages.Script.Spinner` module for executing `BackendTask`s with loading spinners in `elm-pages` scripts.
- `BackendTask.Do` module with helpers for using continuation-style in scripts or `BackendTask` definitions.
- `BackendTask` now carries context that effects verbosity (`quiet`), working directory (`inDir`), and environment variables (`withEnv`).
- New functions in `BackendTask` module: `do`, `doEach`, `failIf`, `sequence`
- `BackendTask` now carries context that effects verbosity (`quiet`), working directory (`inDir`), and environment variables (`withEnv`).
- New functions in `BackendTask` module: `do`, `doEach`, `failIf`, `sequence`
- New functions in `Pages.Script` module: `doThen`, `question`, `sleep`, `which`, `expectWhich`.


## Fixed

- Redirecting to an external URL from an `action` now redirects correctly.
Expand All @@ -59,7 +59,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- Cleaned up handling of navigating to new pages with query parameters, and navigating to links with `#`'s (named anchors). See [#389](https://github.com/dillonkearns/elm-pages/issues/389).
Thank you to [`@kyasu1`](https://github.com/kyasu1) for the issue report and suggested fixes!
Thank you to [`@kyasu1`](https://github.com/kyasu1) for the issue report and suggested fixes!

## [8.0.2] - 2021-08-03

Expand Down
1 change: 0 additions & 1 deletion CHANGELOG-NPM.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Removed invalid internal imports from generated `Main.elm` file.
- Updated NPM dependencies.


## [3.0.13] - 2024-04-28

### Added
Expand Down
13 changes: 7 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Hello! 👋

Thanks for checking out the contributing guide for `elm-pages`! Here are some tips and guidelines to make things as smooth as possible.


## Running (and making changes) locally

I use the elm-pages.com site to test out new ideas locally. You can do the same to see if your changes behave the way you want to.
Expand All @@ -19,6 +18,7 @@ npm start # runs elm-pages develop with the NPM and Elm package code in your rep
```

### Running against your own local `elm-pages` project

If you want to make changes to the `elm-pages` code generation CLI and try running them against your own local project, you can do so by running these commands:

```shell
Expand All @@ -28,6 +28,7 @@ npm install /path/to/cloned/elm-pages
```

This adds something like this to your `devDependencies`:

```json
"elm-pages": "file:../..",
```
Expand All @@ -37,14 +38,14 @@ That has been working very reliably for me, so I can make tweaks and it picks th
Just be sure to change it back in your local project when you're done experimenting by running `npm install --save-dev elm-pages`.

## Performance Profiling the Webpack Build

You can analyze the webpack performance in the Chrome dev tools performance tab.
It's a lot easier than you might imagine. The steps are:

* Comment out this line: https://github.com/dillonkearns/elm-pages/blob/1fa02c015bf391f0223f0504ee7e8cc7f6f1c60b/generator/src/develop.js#L287
* Run `elm-pages build` (with your dev build)
* Drag and drop the `events.json` file that is emitted by the build into the Chrome performance tab (see https://webpack.js.org/plugins/profiling-plugin/)
* You can use the techniques described here to use bottom-up to understand where most of the time is being spent: https://juliu.is/performant-elm/

- Comment out this line: https://github.com/dillonkearns/elm-pages/blob/1fa02c015bf391f0223f0504ee7e8cc7f6f1c60b/generator/src/develop.js#L287
- Run `elm-pages build` (with your dev build)
- Drag and drop the `events.json` file that is emitted by the build into the Chrome performance tab (see https://webpack.js.org/plugins/profiling-plugin/)
- You can use the techniques described here to use bottom-up to understand where most of the time is being spent: https://juliu.is/performant-elm/

## Making pull requests

Expand Down
1 change: 1 addition & 0 deletions docs/2.0-beta.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# elm-pages 2.0 beta

## Setup Instructions

```shell
npx dillonkearns/elm-pages#static-files init elm-pages-demo
cd elm-pages-demo
Expand Down
12 changes: 5 additions & 7 deletions docs/3.0-upgrade-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
- `mkdir app && mv src/Page/ app/Route`
- Move `public/index.js` to the top-level project folder: `mv public/index.js index.js`


## `Shared.elm`

- Change `Cmd Msg` to `Effect Msg`
Expand All @@ -21,9 +20,8 @@
## Secrets

- `Pages.Secrets` is no longer needed! It used to be necessary to ensure that server secrets didn't end up included in data for hydrating the page from your OptimizedDecoders. Now, only the final data payload is optimized (not intermediary data in the pipeline). So if your final `Data` and `ActionData` types on your page do not have any server secrets, then your hydrated data won't either.
- When you didn't use any secrets but did `Secrets.succeed` and pulled in no secrets, you can remove `Secrets.succeed`.
- When you need to use secrets (previously `Pages.Secrets.with`), instead of `Pages.Secrets`, you can now use `BackendTask.Env.expect` to pull in server

- When you didn't use any secrets but did `Secrets.succeed` and pulled in no secrets, you can remove `Secrets.succeed`.
- When you need to use secrets (previously `Pages.Secrets.with`), instead of `Pages.Secrets`, you can now use `BackendTask.Env.expect` to pull in server

## Other Notes

Expand All @@ -34,13 +32,13 @@
- Additional type variable in `StaticPayload`. `StaticPayload Data RouteParams` -> `StaticPayload Data ActionData RouteParams`
- Must expose `ActionData` from each Route Module
- Copy these files from example repo
- `app/ErrorPage.elm`
- `app/Effect.elm`
- `app/ErrorPage.elm`
- `app/Effect.elm`
- `elm-pages add` is replaced by `elm-pages run` for running custom scripts - by convention a script/src/AddRoute.elm script is used for scaffolding a new route.
- `elm-pages codegen` command (to create generated files, helpful for build servers) is renamed to `elm-pages gen`
- Route modules exposed value defining the route used to be called `page`, now needs to be `route`
- In `Route.link` function, the `Route` used to be the first argument, it is now the last argument (works nicely if you pipe the Route in as an argument).
secrets that you need (just don't put sensitive data into your `Data` or `ActionData` types. Example: `BackendTask.Env.expect "MY_ENVIRONMENT_VARIABLE_SECRET" |> BackendTask.andThen (\secret -> myBackendTaskThatUsesASecret secret)`
secrets that you need (just don't put sensitive data into your `Data` or `ActionData` types. Example: `BackendTask.Env.expect "MY_ENVIRONMENT_VARIABLE_SECRET" |> BackendTask.andThen (\secret -> myBackendTaskThatUsesASecret secret)`
- In Shared.elm and Route Modules, `init` and `update` functions no longer return a `Cmd msg` but instead an `Effect msg`
- `Maybe Browser.Navigation.Key` is no longer passed in to `Shared.init`. Instead, you get access to it in `Effect`, so you can create variants in your `Effect` type for anything that needs that type
- `SiteConfig` type no longer has any type variables `SiteConfig Data` -> `SiteConfig`
Expand Down
34 changes: 22 additions & 12 deletions docs/error-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ both in terms of the concepts, and the feel of the development cycle and feedbac

## Error Message Resources & Inspiration

* https://elm-lang.org/news/compiler-errors-for-humans
* https://elm-lang.org/news/the-syntax-cliff
* Gatsby is working on redesignging their CLI error messages, and has listed out a lot of references of
- https://elm-lang.org/news/compiler-errors-for-humans
- https://elm-lang.org/news/the-syntax-cliff
- Gatsby is working on redesignging their CLI error messages, and has listed out a lot of references of
UX ideas for CLIs, and descriptions of CLI UX from common tools: https://www.gatsbyjs.org/blog/2019-05-22-cli-error-redesign

## Error Message Structure
Expand All @@ -34,6 +34,7 @@ How can we present information and resources that help them understand concepts
### Example Breakdown

**CONTEXT**

```
I was trying to parse the file `content/blog/my-post.txt`
Expand All @@ -59,6 +60,7 @@ So you could either:
```

**EDUCATIONAL MATERIAL**

```
You can learn more about how elm-pages deals with parsing different document types,
and some techniques and best practices for managing your content files and metadata types
Expand All @@ -70,40 +72,47 @@ at elm-pages.com/docs/document-handlers
Let's break these down further with some examples and key ideas for each.

### Context

How can we help the user find where/why something went wrong?

Examples of useful context:
* "I was parsing the frontmatter for the file at `./content/blog/my-post.md`"

- "I was parsing the frontmatter for the file at `./content/blog/my-post.md`"

## Suggestion

How can we guide the user to quickly and easily fix the problem or accomplish the task they're trying to accomplish?

Key concepts
* Make it as actionable as possible
* Code snippets should compile when copy-pasted if possible
* List out possible options to make it clear when there are alternatives

Examples:
* See "Suggestion" section in [Example Breakdown](#example-breakdown)
- Make it as actionable as possible
- Code snippets should compile when copy-pasted if possible
- List out possible options to make it clear when there are alternatives

Examples:

- See "Suggestion" section in [Example Breakdown](#example-breakdown)

## Educational Material

How can we present information and resources that help them understand concepts that they might be missing that they need to solve their issue or accomplish their goal?

Key ideas
* Often the user is trying to accomplish something different than the error message context would imply. For

- Often the user is trying to accomplish something different than the error message context would imply. For
example, if they are running into an error message about parsing frontmatter, they may
just need some help understanding the concept of what frontmatter is, what the valid syntax is,
or how it differs from tools with special frontmatter directives (like Jekyll). So the context is
that their decoder is failing... but that context may not point them in the direction they need at all.
This is often the purpose that educational material serves.

Examples:
* "I was trying to parse the frontmatter for page ..., but there was no frontmatter. Frontmatter is metadata about a page, for example a page might have a title or a published date or a list of tags. See link to learn more about frontmatter and best practices for using it with `elm-pages`"
* Many static site frameworks have custom frontmatter directives. In `elm-pages`, you define a JSON decoder, and then decide what to do with that parsed data in your `view` function. Learn more at elm-pages.com/docs/elm-pages-architecture

- "I was trying to parse the frontmatter for page ..., but there was no frontmatter. Frontmatter is metadata about a page, for example a page might have a title or a published date or a list of tags. See link to learn more about frontmatter and best practices for using it with `elm-pages`"
- Many static site frameworks have custom frontmatter directives. In `elm-pages`, you define a JSON decoder, and then decide what to do with that parsed data in your `view` function. Learn more at elm-pages.com/docs/elm-pages-architecture

## Error message design process

Error messages are part of the UX of `elm-pages`. People will be looking at these frequently when they work with `elm-pages`, so
it's a very important part of it. Always consider the user's goal (from the user's perspective) when thinking about error messages.

Expand All @@ -114,6 +123,7 @@ extermely helpful exercise. I envision having Github issues with **current error
and propose changes, or explore them through the lens of this Error Style Guide.

## Where/when to present errors

Let the user know as soon as possible. For example, if you can show them an error in their browser
as they're editing the frontmatter for a document, do that.

Expand Down
2 changes: 0 additions & 2 deletions docs/migrating-from-1-to-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ git submodule add -b static-files https://github.com/dillonkearns/elm-pages.git

Add `"elm-pages/src"` to your `source-directories` in your `elm.json`. Delete the files that `elm-pages` generated in the `gen` folder, or remove it entirely and delete `"gen"` from `source-directories`.


## Install Dependencies

If you'd like to migrate with the beta, you'll need to manually make sure you have these dependencies installed since Elm doesn't have a way to publish beta release packages.
Expand All @@ -22,7 +21,6 @@ elm-json install avh4/[email protected] danyx23/[email protected] dillonkearns/el

There is no `static` or `images` folder in `elm-pages` 2.0, just a single `public/` folder with no special post-processing.


```shell
mv static public
mv images public/images
Expand Down
7 changes: 3 additions & 4 deletions docs/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ Here's a diff to help guide you through the change: https://github.com/dillonkea
If you don't have any StaticHttp data for a given page, you can use `StaticHttp.succeed` (see the
[changes to the view function in the elm-pages-starter diff](https://github.com/dillonkearns/elm-pages-starter/commit/5de5102d706f4a360df94e5493ceff27ebd61587#diff-de84bd170bc37fbce0a7076c0125dd29L110-R142)).


### Step by step upgrade checklist

- Be sure to install the latest NPM package *and* the latest elm package (NPM version 1.1.3 and Elm package version 1.1.0 at
- Be sure to install the latest NPM package _and_ the latest elm package (NPM version 1.1.3 and Elm package version 1.1.0 at
the time of this writing).
- `elm install elm/time` (the generated `Pages.elm` has a new `builtAt` value of
type `Time` so this needs to be installed for it to compile).
- `elm install elm/time` (the generated `Pages.elm` has a new `builtAt` value of
type `Time` so this needs to be installed for it to compile).
- The `init` function now takes an additional argument, the page you're on when you load the app.
You can just add a discarded argument [like this](https://github.com/dillonkearns/elm-pages-starter/commit/5de5102d706f4a360df94e5493ceff27ebd61587#diff-de84bd170bc37fbce0a7076c0125dd29R60).
- The `head` function is [no longer called from `Pages.application`](https://github.com/dillonkearns/elm-pages-starter/commit/5de5102d706f4a360df94e5493ceff27ebd61587#diff-de84bd170bc37fbce0a7076c0125dd29L64) because it now has access to
Expand Down
53 changes: 37 additions & 16 deletions examples/base-path/syntax.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ code.elmsh {
}

code {
font-family: 'Roboto Mono' !important;
font-family: "Roboto Mono" !important;
font-size: 20px !important;
line-height: 28px;
}
Expand All @@ -26,18 +26,39 @@ code {
}

.elmsh {
color: #f8f8f2;
background: #000;
}
.elmsh-hl {background: #343434;}
.elmsh-add {background: #003800;}
.elmsh-del {background: #380000;}
.elmsh-comm {color: #75715e;}
.elmsh1 {color: #ae81ff;}
.elmsh2 {color: #e6db74;}
.elmsh3 {color: #66d9ef;}
.elmsh4 {color: #f92672;}
.elmsh5 {color: #a6e22e;}
.elmsh6 {color: #ae81ff;}
.elmsh7 {color: #fd971f;}

color: #f8f8f2;
background: #000;
}
.elmsh-hl {
background: #343434;
}
.elmsh-add {
background: #003800;
}
.elmsh-del {
background: #380000;
}
.elmsh-comm {
color: #75715e;
}
.elmsh1 {
color: #ae81ff;
}
.elmsh2 {
color: #e6db74;
}
.elmsh3 {
color: #66d9ef;
}
.elmsh4 {
color: #f92672;
}
.elmsh5 {
color: #a6e22e;
}
.elmsh6 {
color: #ae81ff;
}
.elmsh7 {
color: #fd971f;
}
2 changes: 0 additions & 2 deletions examples/docs/content/blog/types-over-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ Each file in the `content` folder will result in a new route for your static sit

Now, in our `elm-pages` app, our `view` function will get the markdown that we rendered for a given page along with the corresponding `Metadata`. It's completely in our hands what we want to do with that data.


<Oembed url="https://twitter.com/czaplic/status/928359289135046656" />


## Takeaways

So which is better, configuration through types or configuration by convention?
Expand Down
3 changes: 1 addition & 2 deletions examples/docs/content/docs/11-remote-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: You can share `elm-pages` scripts hosted in GitHub Repos or Gists,

You can share `elm-pages` scripts hosted in GitHub Repos or Gists, and run them locally with a single command.

```
```
npx elm-pages@latest run https://github.com/dillonkearns/elm-pages-starter/blob/master/script/src/Stars.elm
622
Expand Down Expand Up @@ -37,7 +37,6 @@ Here is a list of all the supported formats for executing a remote script from a
- `https://raw.githubusercontent.com/dillonkearns/elm-pages-starter/blob/4bc22294053279418e37fae64a64125d6d116ded/script/src/Stars.elm`
- `github:dillonkearns/elm-pages-starter:script/src/Stars.elm`


## Running a remote script from a GitHub Gist:

You can also run a script from a GitHub Gist by passing in the URL to the gist. This is often a faster and easier way to create and share a simple script so it's a convenient method.
Expand Down
4 changes: 2 additions & 2 deletions examples/docs/lib/native-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* this.constructor so that the native HTMLElement constructor can access the
* current under-construction element's definition.
*/
(function() {
(function () {
if (
// No Reflect, no classes, no need for shim because native custom elements
// require ES2015 classes or Reflect.
Expand All @@ -40,7 +40,7 @@
[],
/** @type {!Function} */ (this.constructor)
);
}
},
};
window.HTMLElement = wrapperForTheName["HTMLElement"];
HTMLElement.prototype = BuiltInHTMLElement.prototype;
Expand Down
Loading

0 comments on commit e6d7164

Please sign in to comment.