Skip to content

Commit af650be

Browse files
authored
feat: add perttier to format the markdown files (#124)
1 parent a9f4bb9 commit af650be

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

.github/CONTRIBUTING.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ Boot up the documentation site locally, with live reloading of the source code:
4646
$ pnpm run docs:dev
4747
```
4848

49-
If you made a lot of changes, run the following command to check for typos before submitting a pull request:
49+
If you made a lot of changes, run the following command to check for typos & format the docs before submitting a pull request:
50+
51+
> Generally, `nix develop` will add a pre-commit hook to run the following command before you commit.
5052
5153
```sh
5254
$ typos -w
55+
$ prettier --write .
5356
```
5457

5558
After executing the above command, visit <http://localhost:5173> and try modifying the source code. You'll get live update.

.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
LICENSE.md
2+
dist
3+
pnpm-lock.yaml
4+
flake.lock
5+
vercel.json
6+
cache
7+
temp
8+
.temp

.prettierrc.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://prettier.io/docs/en/options
2+
semi: false
3+
singleQuote: false
4+
printWidth: 80
5+
trailingComma: es5

README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ An unofficial and opinionated NixOS & Flakes :book: for beginners: https://nixos
1111
> If you're using macOS, [ryan4yin/nix-darwin-kickstarter](https://github.com/ryan4yin/nix-darwin-kickstarter) may be a good starting point for you,
1212
> you can learn how to use Nix with this book and take nix-darwin-kickstarter as a start point to build your own Nix configuration.
1313
14-
1514
## Feedback and Discussion
1615

17-
I’m not an expert on NixOS, and I’ve only been using NixOS for less than 9 months until now(2024-02),
16+
I’m not an expert on NixOS, and I’ve only been using NixOS for less than 9 months until now(2024-02),
1817
so there must be some misconceptions or inappropriate examples in the book.
1918
If anyone finds anything incorrect or have any questions / suggestions, just let me know about it by open an issue or join the discussion on [GitHub Discussions](https://github.com/ryan4yin/nixos-and-flakes-book/discussions), I'm glad continue to optimize the content of this book.
2019

@@ -24,7 +23,6 @@ Even though I knew I could make mistakes, it's much better than do nothing.
2423
My hope is that this book can help more people, enabling them to experience the joys of NixOS.
2524
Hope you like it!
2625

27-
2826
## Introduction to Flakes
2927

3028
The flakes experimental feature is a major development for Nix, it introduces a policy for managing dependencies between Nix expressions, it improves reproducibility, composability and usability in the Nix ecosystem. Although it's still an experimental feature, flakes have been widely used by the Nix community.[^1]
@@ -58,7 +56,6 @@ Thank you to [all the people](https://github.com/ryan4yin/nixos-and-flakes-book/
5856

5957
[NixOS & Flakes Book](https://github.com/ryan4yin/nixos-and-flakes-book) © 2023 by Ryan Yin is licensed under [CC BY-SA 4.0](./LICENSE.md)
6058

61-
6259
[^1]: [Flakes - NixOS Wiki](https://nixos.wiki/index.php?title=Flakes)
6360
[^2]: [Flakes are such an obviously good thing](https://grahamc.com/blog/flakes-are-an-obviously-good-thing/)
6461
[^3]: [Draft: 1 year roadmap - NixOS Foundation](https://nixos-foundation.notion.site/1-year-roadmap-0dc5c2ec265a477ea65c549cd5e568a9)

flake.nix

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
nodejs = super.nodejs_20;
2020
pnpm = super.nodePackages.pnpm;
2121
yarn = super.yarn.override {inherit nodejs;};
22+
prettier = super.nodePackages.prettier;
2223
})
2324
];
2425
pkgs = import nixpkgs {inherit overlays system;};
@@ -28,6 +29,7 @@
2829
nodejs
2930
pnpm
3031
yarn
32+
prettier
3133

3234
git
3335
typos
@@ -40,12 +42,17 @@
4042
hooks = {
4143
typos.enable = true; # Source code spell checker
4244
alejandra.enable = true; # Nix linter
45+
prettier.enable = true; # Markdown & TS formatter
4346
};
4447
settings = {
4548
typos = {
4649
write = true; # Automatically fix typos
4750
ignored-words = [];
4851
};
52+
prettier = {
53+
write = true; # Automatically format files
54+
configPath = "./.prettierrc.yaml";
55+
};
4956
};
5057
};
5158
};

0 commit comments

Comments
 (0)