Skip to content

Commit ad42f6a

Browse files
authored
Merge pull request #230 from yuanw/astro-build
use Astro build
2 parents ae75b65 + 5be5145 commit ad42f6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+25850
-65
lines changed

flake.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,75 +8,45 @@
88
flake-root.url = "github:srid/flake-root";
99
treefmt-nix.url = "github:numtide/treefmt-nix";
1010
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
11-
devenv.url = "github:cachix/devenv";
11+
devenv.url = "github:cachix/devenv";
1212
};
1313
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
1414
flake-parts.lib.mkFlake { inherit inputs; } {
1515
systems = [ "x86_64-linux" "aarch64-darwin" ];
1616
imports = [
17-
inputs.haskell-flake.flakeModule
1817
inputs.flake-root.flakeModule
1918
inputs.treefmt-nix.flakeModule
20-
inputs.devenv.flakeModule
19+
inputs.devenv.flakeModule
20+
21+
./mechanical-meridian/flake-module.nix
2122
];
2223
perSystem = { self', lib, config, pkgs, ... }:
23-
let
24-
mkBlogContent = { includeDraft ? false }:
25-
pkgs.stdenv.mkDerivation {
26-
pname =
27-
if includeDraft then "blog-content-preview" else "blog-content";
28-
version = "0.0.4";
29-
buildInputs = [ pkgs.glibcLocales ];
30-
LANG = "en_US.UTF-8";
31-
PREVIEW = if includeDraft then "TRUE" else "FALSE";
32-
src = ./.;
33-
buildPhase = ''
34-
${self'.packages.blog}/bin/blog rebuild
35-
mkdir $out
36-
'';
37-
installPhase = ''
38-
mv dist/* $out
39-
'';
40-
};
41-
in
42-
{
4324

44-
packages.blogContent = mkBlogContent { };
45-
packages.draftContent = mkBlogContent { includeDraft = true; };
25+
{
26+
packages.nodejs = pkgs.nodejs_22;
4627

47-
haskellProjects.default = {
48-
projectRoot = ./src;
49-
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
50-
devShell = {
51-
hlsCheck.enable = false;
52-
};
53-
};
5428
treefmt.config = {
5529
inherit (config.flake-root) projectRootFile;
5630
package = pkgs.treefmt;
57-
programs.ormolu.enable = true;
5831
programs.nixpkgs-fmt.enable = true;
59-
programs.cabal-fmt.enable = true;
60-
programs.hlint.enable = true;
61-
# We use fourmolu
62-
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
63-
settings.formatter.ormolu = {
64-
options = [ "--ghc-opt" "-XImportQualifiedPost" ];
65-
};
6632
};
67-
68-
packages.default = config.packages.blogContent;
6933
devenv.shells.default = {
7034
# https://devenv.sh/reference/options/
7135
packages = [
7236
config.treefmt.build.wrapper
73-
] ++ config.haskellProjects.default.outputs.devShell.nativeBuildInputs
74-
++ config.haskellProjects.default.outputs.devShell.buildInputs;
37+
config.packages.nodejs
38+
39+
];
7540

7641
scripts.preview.exec = ''
77-
warp -d ${config.packages.blogContent}
42+
${pkgs.haskellPackages.wai-app-static}/bin/warp -d ${config.packages.blog}
7843
'';
7944
};
45+
46+
packages.default = config.packages.blog;
47+
48+
49+
8050
};
8151
};
8252
}

mechanical-meridian/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# build output
2+
dist/
3+
# generated types
4+
.astro/
5+
6+
# dependencies
7+
node_modules/
8+
9+
# logs
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
pnpm-debug.log*
14+
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"recommendations": ["astro-build.astro-vscode"],
3+
"unwantedRecommendations": []
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"command": "./node_modules/.bin/astro dev",
6+
"name": "Development server",
7+
"request": "launch",
8+
"type": "node-terminal"
9+
}
10+
]
11+
}

mechanical-meridian/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Starlight Starter Kit: Basics
2+
3+
[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
4+
5+
```
6+
npm create astro@latest -- --template starlight
7+
```
8+
9+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
10+
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
11+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)
12+
13+
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
14+
15+
## 🚀 Project Structure
16+
17+
Inside of your Astro + Starlight project, you'll see the following folders and files:
18+
19+
```
20+
.
21+
├── public/
22+
├── src/
23+
│ ├── assets/
24+
│ ├── content/
25+
│ │ ├── docs/
26+
│ │ └── config.ts
27+
│ └── env.d.ts
28+
├── astro.config.mjs
29+
├── package.json
30+
└── tsconfig.json
31+
```
32+
33+
Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
34+
35+
Images can be added to `src/assets/` and embedded in Markdown with a relative link.
36+
37+
Static assets, like favicons, can be placed in the `public/` directory.
38+
39+
## 🧞 Commands
40+
41+
All commands are run from the root of the project, from a terminal:
42+
43+
| Command | Action |
44+
| :------------------------ | :----------------------------------------------- |
45+
| `npm install` | Installs dependencies |
46+
| `npm run dev` | Starts local dev server at `localhost:4321` |
47+
| `npm run build` | Build your production site to `./dist/` |
48+
| `npm run preview` | Preview your build locally, before deploying |
49+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
50+
| `npm run astro -- --help` | Get help using the Astro CLI |
51+
52+
## 👀 Want to learn more?
53+
54+
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).

mechanical-meridian/astro.config.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defineConfig } from 'astro/config';
2+
import starlight from '@astrojs/starlight';
3+
import starlightBlog from 'starlight-blog';
4+
5+
// https://astro.build/config
6+
export default defineConfig({
7+
integrations: [
8+
starlight({
9+
title: 'Yuan Wang',
10+
plugins: [starlightBlog()],
11+
social: {
12+
github: 'https://github.com/yuanw/blog',
13+
},
14+
sidebar: [
15+
{
16+
label: 'Guides',
17+
items: [
18+
// Each item here is one entry in the navigation menu.
19+
{ label: 'Example Guide', link: '/guides/example/' },
20+
],
21+
},
22+
{
23+
label: 'Reference',
24+
autogenerate: { directory: 'reference' },
25+
},
26+
],
27+
}),
28+
],
29+
});

mechanical-meridian/flake-module.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
perSystem = { config, self', inputs', pkgs, lib, system, ... }: {
3+
checks = config.packages;
4+
5+
packages.blog = pkgs.buildNpmPackage {
6+
pname = "blog";
7+
version = "0.2.0";
8+
9+
inherit (config.packages) nodejs;
10+
11+
src = ./.;
12+
13+
buildInputs = [
14+
pkgs.vips
15+
];
16+
17+
nativeBuildInputs = [
18+
pkgs.pkg-config
19+
];
20+
21+
installPhase = ''
22+
runHook preInstall
23+
cp -pr --reflink=auto dist $out/
24+
runHook postInstall
25+
'';
26+
npmDepsHash = "sha256-xvDnu81wK10uGVA9VI98WaKAQ8o9ou+FVBJo5r5bClE=";
27+
28+
};
29+
};
30+
}

0 commit comments

Comments
 (0)