Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-language emanote sites #21

Merged
merged 9 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

This website is built using [Emanote](https://emanote.srid.ca/).

To run it locally with live preview,
To run the English site locally with live preview,

```sh
nix run
nix run .#en
```

## Goals
Expand All @@ -25,6 +25,20 @@ Contents are stored in Markdown and can be edited using your favourite [text edi

To assist the reviewer, use `nix run github:nixos-asia/website/branch#preview -- -o /en/whatever` in the PR description to provide a handy command for previewing the changes in the PR. See example: https://github.com/nixos-asia/website/pull/12


### Content organization

This site is made of multiple Emanote layers:

- `./global`: Static files and HTML temlpates (common to all languages)
- If a note uses images, you should put them here.
- Language-specific content:
- `./en`: English content
- `./fr`: French content[^fr]

[^fr]: This is just a placeholder. See https://github.com/nixos-asia/website/issues/18


## Discussion

We hang out in [Zulip](https://nixos.zulipchat.com/) ― come say hi.
5 changes: 0 additions & 5 deletions en.md → en/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
emanote:
folder-folgezettel: false
---

# NixOS Asia

> [!tip] Welcome to NixOS Asia
Expand Down
4 changes: 4 additions & 0 deletions en/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
page:
lang: en
template:
editBaseUrl: https://github.com/nixos-asia/website/edit/master/en
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 59 additions & 24 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,66 @@
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.emanote.flakeModule ];
perSystem = { self', pkgs, system, ... }: {
emanote = {
# By default, the 'emanote' flake input is used.
# package = inputs.emanote.packages.${system}.default;
sites."default" = {
layers = [ ./. ];
layersString = [ "." ];
port = 7788;
prettyUrls = true;
perSystem = { self', pkgs, lib, system, ... }:
let
langs = {
en = { path = ./en; port = 7788; };
fr = { path = ./fr; port = 7789; };
};
in
{
emanote = {
sites = lib.mapAttrs
(name: lang: {
inherit (lang) port;
layers = [ lang.path ./global ];
layersString = [ name "global" ];
prettyUrls = true;
baseUrl = "/${name}/";
basePath = name;
})
langs;
};
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.nixpkgs-fmt
];
};
packages = rec {
indexPage = pkgs.writeTextDir
"index.html"
''
<html>
<head>
<meta charset="utf-8" />
<title>Welcome to NixOS Asia</title>
<!-- meta http-equiv="refresh" content="0; URL=/en" /-->
</head>
<body>
<!-- TODO: Lang selector? -->
<div style="margin-top: 2em; text-align: center; font-size: 2em;">
<a href="/en">English</a> | <a href="/fr">Français</a>
</div>
</body>
</html>
'';
site = pkgs.symlinkJoin {
name = "nixos-asia-site";
paths = [ indexPage ] ++ lib.mapAttrsToList
(name: _: self'.packages.${name})
langs;
};
default = site;
};
apps.preview.program = pkgs.writeShellApplication {
name = "emanote-preview";
runtimeInputs = [ pkgs.nodePackages.http-server ];
text = ''
set -x
http-server ${self'.packages.default} "$@"
'';
};
formatter = pkgs.nixpkgs-fmt;
};
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.nixpkgs-fmt
];
};
apps.preview.program = pkgs.writeShellApplication {
name = "emanote-preview";
runtimeInputs = [ pkgs.nodePackages.http-server ];
text = ''
set -x
http-server ${self'.packages.default} "$@"
'';
};
formatter = pkgs.nixpkgs-fmt;
};
};
}
3 changes: 3 additions & 0 deletions fr/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# NixOS Asie

> [!warning] La version française n'est pas encore écrite.
5 changes: 5 additions & 0 deletions fr/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
page:
lang: fr
siteTitle: NixOS Asie
template:
editBaseUrl: https://github.com/nixos-asia/website/edit/master/fr
5 changes: 0 additions & 5 deletions index.yaml → global/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ template:
theme: green
iconUrl: static/nixos-asia.svg

# You can add your own variables here, like editBaseUrl.
# See after-note.tpl to see where editBaseUrl gets used.
editBaseUrl: https://github.com/nixos-asia/website/edit/master

uptree:
enable: false

# If you are hosting on GitLab Pages, you may want to remove this.
urlStrategy: pretty

feed:
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
15 changes: 0 additions & 15 deletions index.md

This file was deleted.

25 changes: 0 additions & 25 deletions templates/home.tpl

This file was deleted.