diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..361842c442 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Format: run on all files +690acaad552afe771806443c3c8c93efe32f71a9 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19eb0941f5..92ba47409d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,6 @@ concurrency: cancel-in-progress: true jobs: - build: name: "Build nixos.org" runs-on: "ubuntu-latest" @@ -26,7 +25,6 @@ jobs: if: "!contains(github.event.head_commit.message, '[ci skip]')" steps: - - name: "Checking out the repository" uses: "actions/checkout@v4" with: @@ -39,7 +37,12 @@ jobs: uses: "cachix/cachix-action@v15" with: name: "nixos-homepage" - signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' + signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" + + - name: "Check formatting" + run: | + npm install + npm run format:check - name: "Build" run: | diff --git a/.prettierrc.mjs b/.prettierrc.mjs new file mode 100644 index 0000000000..7e619305dc --- /dev/null +++ b/.prettierrc.mjs @@ -0,0 +1,12 @@ +/** @type {import("prettier").Config} */ +export default { + plugins: ["prettier-plugin-astro"], + overrides: [ + { + files: "*.astro", + options: { + parser: "astro", + }, + }, + ], +}; diff --git a/astro.config.mjs b/astro.config.mjs index f234bd516d..0dc23b3ae3 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,4 +1,4 @@ -import { defineConfig } from 'astro/config'; +import { defineConfig } from "astro/config"; import mdx from "@astrojs/mdx"; import sitemap from "@astrojs/sitemap"; @@ -6,21 +6,21 @@ import tailwind from "@astrojs/tailwind"; import icon from "astro-icon"; // theme derivated from https://raw.githubusercontent.com/shikijs/textmate-grammars-themes/main/packages/tm-themes/themes/vesper.json -import syntaxTheme from "./src/lib/shiki/theme.json" +import syntaxTheme from "./src/lib/shiki/theme.json"; // https://astro.build/config export default defineConfig({ - output: 'static', - site: 'https://nixos.org', + output: "static", + site: "https://nixos.org", integrations: [ tailwind(), mdx(), sitemap(), icon({ include: { - mdi: ['*'], - simpleIcons: ['*'], - } + mdi: ["*"], + simpleIcons: ["*"], + }, }), ], markdown: { diff --git a/flake.nix b/flake.nix index de7216bf4c..c745590989 100644 --- a/flake.nix +++ b/flake.nix @@ -186,7 +186,7 @@ rec { done ''; - in rec { + in { packages.manuals = manuals; packages.pills = pills; packages.demos = demos; diff --git a/package-lock.json b/package-lock.json index 34ad060e7e..a9d5387475 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,9 @@ "devDependencies": { "@iconify-json/mdi": "^1.1.67", "@iconify-json/simple-icons": "^1.1.107", - "@iconify/tailwind": "^1.1.1" + "@iconify/tailwind": "^1.1.1", + "prettier": "^3.3.2", + "prettier-plugin-astro": "^0.14.0" } }, "node_modules/@alloc/quick-lru": { @@ -6521,6 +6523,41 @@ "node": ">=8.15" } }, + "node_modules/prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "devOptional": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-astro": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-astro/-/prettier-plugin-astro-0.14.0.tgz", + "integrity": "sha512-7jRGJsexaRIyUzTk8uzXlP45cw6DQ5Ci4bTe0xCBCcuO1Fff8jJy9oI+kRCQKSdDFTSAArMSg8GpvzlKBtSaZA==", + "devOptional": true, + "dependencies": { + "@astrojs/compiler": "^1.5.5", + "prettier": "^3.0.0", + "sass-formatter": "^0.7.6" + }, + "engines": { + "node": "^14.15.0 || >=16.0.0" + } + }, + "node_modules/prettier-plugin-astro/node_modules/@astrojs/compiler": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-1.8.2.tgz", + "integrity": "sha512-o/ObKgtMzl8SlpIdzaxFnt7SATKPxu4oIP/1NL+HDJRzxfJcAkOTAb/ZKMRyULbz4q+1t2/DAebs2Z1QairkZw==", + "devOptional": true + }, "node_modules/prismjs": { "version": "1.29.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", @@ -6957,6 +6994,12 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/s.color": { + "version": "0.0.15", + "resolved": "https://registry.npmjs.org/s.color/-/s.color-0.0.15.tgz", + "integrity": "sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==", + "devOptional": true + }, "node_modules/sanitize-html": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.13.0.tgz", @@ -6981,6 +7024,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/sass-formatter": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/sass-formatter/-/sass-formatter-0.7.9.tgz", + "integrity": "sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==", + "devOptional": true, + "dependencies": { + "suf-log": "^2.5.3" + } + }, "node_modules/sax": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", @@ -7369,6 +7421,15 @@ "node": ">= 6" } }, + "node_modules/suf-log": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/suf-log/-/suf-log-2.5.3.tgz", + "integrity": "sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==", + "devOptional": true, + "dependencies": { + "s.color": "0.0.15" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", diff --git a/package.json b/package.json index 7ced666eb0..0e8e8b8086 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,9 @@ "preview": "astro preview", "astro": "astro", "linkcheck:minimal": "linkchecker http://localhost:4321 --ignore-url /manual --ignore-url /guides --ignore-url /tutorials", - "linkcheck:full": "linkchecker http://localhost:4321" + "linkcheck:full": "linkchecker http://localhost:4321", + "format": "prettier --write ./src", + "format:check": "prettier --check ./src" }, "dependencies": { "@astrojs/mdx": "^3.1.2", @@ -37,7 +39,9 @@ }, "devDependencies": { "@iconify-json/mdi": "^1.1.67", + "@iconify/tailwind": "^1.1.1", "@iconify-json/simple-icons": "^1.1.107", - "@iconify/tailwind": "^1.1.1" + "prettier": "^3.3.2", + "prettier-plugin-astro": "^0.14.0" } } diff --git a/src/components/layout/CodeBlock.astro b/src/components/layout/CodeBlock.astro index 701ef16729..49424a74cb 100644 --- a/src/components/layout/CodeBlock.astro +++ b/src/components/layout/CodeBlock.astro @@ -1,22 +1,24 @@ --- interface Props { - lines: Array<{ shellPrompt: string, code: string }>; + lines: Array<{ shellPrompt: string; code: string }>; type?: "code" | "storepath"; } const { lines, type = "code" } = Astro.props; --- -
{lines.map((line, idx, {length}) => { if (length - 1 === idx) { - returndiff --git a/src/components/layout/CodeInline.astro b/src/components/layout/CodeInline.astro index 2f3ff2ec0a..a5de2f1c5b 100644 --- a/src/components/layout/CodeInline.astro +++ b/src/components/layout/CodeInline.astro @@ -1,4 +1,7 @@ --- + --- -{line.shellPrompt}
{line.code} - } else { - return{line.shellPrompt}
{line.code}
- } + return{line.shellPrompt}
{line.code}} else { + return{line.shellPrompt}
{line.code}
} })}
+
diff --git a/src/components/layout/Container.astro b/src/components/layout/Container.astro
index f98de5a56a..0382f7f2fc 100644
--- a/src/components/layout/Container.astro
+++ b/src/components/layout/Container.astro
@@ -2,6 +2,9 @@
const { class: extraClasses, id = null } = Astro.props;
---
-