|
24 | 24 | builtins.filter (name: if name == "docs" then isLinux else true) exampleDirs |
25 | 25 | ); |
26 | 26 |
|
| 27 | + exampleMeta = { |
| 28 | + docs = { files = [ "build.nix" "components.nix" "options.nix" ]; }; |
| 29 | + }; |
| 30 | + |
27 | 31 | showcaseStyles = '' |
28 | 32 | * { box-sizing: border-box; margin: 0; padding: 0; } |
29 | 33 | body { display: flex; flex-direction: column; height: 100vh; font-family: system-ui, sans-serif; background: #1a1a2e; color: #ccc; } |
|
33 | 37 | .topbar .current { color: #fff; text-decoration: underline; text-underline-offset: 3px; } |
34 | 38 | .content { display: flex; flex: 1; min-height: 0; } |
35 | 39 | .source { flex: 1; overflow: auto; padding: 1rem; border-right: 1px solid #333; } |
36 | | - .source pre { margin: 0; font-size: 0.8rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; } |
37 | | - .source code { font-family: ui-monospace, monospace; } |
| 40 | + .file { margin-top: 1rem; } |
| 41 | + .file:first-child { margin-top: 0; } |
| 42 | + .file h3 { display: inline-block; font-size: 0.7rem; font-weight: 600; color: #aaa; background: #252540; padding: 0.3rem 0.6rem; border-radius: 4px 4px 0 0; margin: 0; } |
| 43 | + .file pre { margin: 0; padding: 0.8rem; font-size: 0.8rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; background: #12121f; border-radius: 0 4px 4px 4px; } |
| 44 | + .file code { font-family: ui-monospace, monospace; } |
38 | 45 | .preview { flex: 1; } |
39 | 46 | .preview iframe { width: 100%; height: 100%; border: none; } |
40 | 47 | ''; |
|
50 | 57 | (builtins.tail (pkgs.lib.concatMap (name: [ " - " (exampleLink current name) ]) exampleNames)) |
51 | 58 | ]; |
52 | 59 |
|
| 60 | + renderFile = name: file: [ "div.file" |
| 61 | + [ "h3" file ] |
| 62 | + [ "pre" [ "code" (builtins.readFile ./examples/${name}/${file}) ] ] |
| 63 | + ]; |
| 64 | + |
53 | 65 | wrapExample = name: drv: |
54 | 66 | let |
55 | | - source = builtins.readFile ./examples/${name}/build.nix; |
| 67 | + meta = exampleMeta.${name} or {}; |
| 68 | + files = meta.files or [ "build.nix" ]; |
56 | 69 | page = h.render [ "html" { lang = "en"; } |
57 | 70 | [ "head" |
58 | 71 | [ "meta" { charset = "utf-8"; } ] |
|
62 | 75 | [ "body" |
63 | 76 | (navBar name) |
64 | 77 | [ "div.content" |
65 | | - [ "div.source" [ "pre" [ "code" source ] ] ] |
| 78 | + [ "div.source" (map (renderFile name) files) ] |
66 | 79 | [ "div.preview" [ "iframe" { src = "demo/"; } ] ] |
67 | 80 | ] |
68 | 81 | ] |
|
0 commit comments