@tuqulore-inc/create-eleventy 5.0.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,29 +1,29 @@
1
1
  # @tuqulore-inc/create-eleventy
2
2
 
3
- Eleventy + Preact + TailwindCSS のプロジェクトを作成するCLIツール
3
+ CLI for creating an Eleventy + Preact + Tailwind CSS project.
4
4
 
5
- ## 使い方
5
+ ## Usage
6
6
 
7
7
  ```bash
8
- # インタラクティブモード
8
+ # Interactive mode
9
9
  pnpm create @tuqulore-inc/eleventy my-project
10
10
 
11
- # テンプレート指定
11
+ # With a template
12
12
  pnpm create @tuqulore-inc/eleventy my-project --template default
13
13
  ```
14
14
 
15
- ## オプション
15
+ ## Options
16
16
 
17
- | オプション | 説明 |
18
- | ----------------------- | -------------------------- |
19
- | `-t, --template <name>` | 使用するテンプレートを指定 |
20
- | `-h, --help` | ヘルプを表示 |
17
+ | Option | Description |
18
+ | ----------------------- | --------------- |
19
+ | `-t, --template <name>` | Pick a template |
20
+ | `-h, --help` | Show help |
21
21
 
22
- ## 利用可能なテンプレート
22
+ ## Available templates
23
23
 
24
- - `default` - Preact + TailwindCSS の標準構成
24
+ - `default` — Preact + Tailwind CSS
25
25
 
26
- ## プロジェクト作成後
26
+ ## After creation
27
27
 
28
28
  ```bash
29
29
  cd my-project
@@ -31,6 +31,6 @@ pnpm install
31
31
  pnpm dev
32
32
  ```
33
33
 
34
- ## ライセンス
34
+ ## License
35
35
 
36
36
  MIT
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
- import { parseArgs } from "node:util";
5
4
  import readline from "node:readline";
5
+ import { parseArgs } from "node:util";
6
6
 
7
7
  const { values, positionals } = parseArgs({
8
8
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuqulore-inc/create-eleventy",
3
- "version": "5.0.1",
3
+ "version": "5.2.0",
4
4
  "description": "Create a new Eleventy project with Preact and TailwindCSS",
5
5
  "keywords": [
6
6
  "create",
@@ -8,14 +8,13 @@
8
8
  "preact",
9
9
  "tailwindcss"
10
10
  ],
11
+ "license": "MIT",
12
+ "author": "tuqulore inc.",
11
13
  "repository": {
12
14
  "type": "git",
13
15
  "url": "git+https://github.com/tuqulore/website-boilerplate.git",
14
16
  "directory": "packages/create-eleventy"
15
17
  },
16
- "license": "MIT",
17
- "author": "tuqulore inc.",
18
- "type": "module",
19
18
  "bin": {
20
19
  "create-eleventy": "./index.js"
21
20
  },
@@ -23,19 +22,20 @@
23
22
  "index.js",
24
23
  "templates"
25
24
  ],
25
+ "type": "module",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
26
29
  "scripts": {
27
- "lint": "eslint --fix .",
30
+ "lint": "oxlint --fix",
28
31
  "test": "node --test"
29
32
  },
30
33
  "devDependencies": {
31
- "@tuqulore-inc/eslint-config": "5.0.1",
32
- "eslint": "^10.0.0"
34
+ "@tuqulore-inc/oxlint-config": "5.2.0",
35
+ "oxlint": "^1.75.0"
33
36
  },
34
37
  "engines": {
35
38
  "node": ">=20"
36
39
  },
37
- "publishConfig": {
38
- "access": "public"
39
- },
40
- "gitHead": "5966820d0ada95a8b172a8c0890150d8b1a3a543"
40
+ "gitHead": "3a7e70740dd461a8abf17fb582e36aa630962cbc"
41
41
  }
@@ -1,78 +1,78 @@
1
1
  # My Eleventy Site
2
2
 
3
- ## 動作環境
3
+ ## Requirements
4
4
 
5
5
  - [Active LTS](https://github.com/nodejs/release#release-schedule)
6
6
  - Docker
7
7
 
8
- ## クイックスタート
8
+ ## Quick start
9
9
 
10
10
  > [!NOTE]
11
11
  >
12
- > 事前に [pnpmをインストール](https://pnpm.io/ja/installation)してください。
12
+ > Install [pnpm](https://pnpm.io/installation) first.
13
13
 
14
14
  ```shell
15
- pnpm install # npmパッケージのインストール
16
- pnpm dev # 開発サーバーの起動
15
+ pnpm install # install dependencies
16
+ pnpm dev # start the dev server
17
17
  ```
18
18
 
19
- ## npmスクリプト
19
+ ## npm scripts
20
20
 
21
- | タスク名 | 説明 |
22
- | :------- | :--------------------------- |
23
- | build | 静的サイト生成します。 |
24
- | clean | ビルド成果物を取り除きます。 |
25
- | dev | 開発サーバーを起動します。 |
26
- | format | コード整形します。 |
27
- | lint | 静的コード検査します。 |
21
+ | Task | Description |
22
+ | :----- | :------------------------ |
23
+ | build | Generate the static site. |
24
+ | clean | Remove build artifacts. |
25
+ | dev | Start the dev server. |
26
+ | format | Format code. |
27
+ | lint | Run static checks. |
28
28
 
29
- ## 環境変数
29
+ ## Environment variables
30
30
 
31
- | 変数名 | 説明 |
32
- | :------- | :-------------------------------------- |
33
- | SITE_URL | 本リポジトリで構築するサイトのURL。必須 |
31
+ | Name | Description |
32
+ | :------- | :-------------------------------------------------------- |
33
+ | SITE_URL | The URL of the site built from this repository. Required. |
34
34
 
35
- ### カスケーディング (`pnpm dev`)
35
+ ### Cascade (`pnpm dev`)
36
36
 
37
37
  1. .env
38
38
  2. .env.development
39
39
  3. .env.local
40
40
  4. .env.development.local
41
41
 
42
- の順番で参照します。後に参照される値が優先されます。リポジトリに含めない環境変数は.env.localあるいは.env.development.localに記述してください。
42
+ They are read in that order; later values win. Put values that should not be committed into `.env.local` or `.env.development.local`.
43
43
 
44
- ### カスケーディング (`pnpm build`)
44
+ ### Cascade (`pnpm build`)
45
45
 
46
46
  1. .env
47
47
  2. .env.production
48
48
  3. .env.local
49
49
  4. .env.production.local
50
50
 
51
- の順番で参照します。後に参照される値が優先されます。リポジトリに含めない環境変数は.env.productionあるいは.env.production.localに記述してください。
51
+ They are read in that order; later values win. Put values that should not be committed into `.env.local` or `.env.production.local`.
52
52
 
53
- ## 採用しているライブラリ
53
+ ## Libraries used
54
54
 
55
55
  ### [Eleventy](https://www.11ty.dev/)
56
56
 
57
- 静的サイト生成するためのライブラリです。
57
+ A static site generator.
58
58
 
59
59
  ### [Preact](https://preactjs.com/)
60
60
 
61
- JSXテンプレートから動的な振る舞いとHTMLを生成するためのライブラリです。
61
+ Renders JSX templates into HTML with dynamic behavior.
62
62
 
63
63
  ### [Tailwind CSS](https://tailwindcss.com/)
64
64
 
65
- 見た目を実装するためのユーティリティファーストなCSSフレームワークです。
65
+ A utility-first CSS framework for the look and feel.
66
66
 
67
67
  ### [Jumpu UI](https://github.com/tuqulore/jumpu-ui)
68
68
 
69
- 一貫性のある見た目を実装するためのユーティリティフレンドリーなデザインシステムです。
69
+ A utility-friendly design system for a consistent look and feel.
70
70
 
71
71
  ### [Iconify SVG Framework](https://docs.iconify.design/icon-components/svg-framework/)
72
72
 
73
- SVGアイコンを参照するためのライブラリです。
73
+ Provides SVG icons.
74
74
 
75
- ## ディレクトリ構成
75
+ ## Directory layout
76
76
 
77
77
  ```
78
78
  .
@@ -86,44 +86,44 @@ SVGアイコンを参照するためのライブラリです。
86
86
 
87
87
  ### dist
88
88
 
89
- ビルド成果物の出力先です。
89
+ The build output directory.
90
90
 
91
91
  ### src
92
92
 
93
- Eleventyテンプレートの参照先です。
93
+ Eleventy's template input root.
94
94
 
95
95
  ### src/\_data
96
96
 
97
- [グローバルデータ](https://www.11ty.dev/docs/data-global/)を配置します。
97
+ Where [global data](https://www.11ty.dev/docs/data-global/) lives.
98
98
 
99
99
  ### src/\_includes
100
100
 
101
- [レイアウトチェイニング](https://www.11ty.dev/docs/layout-chaining/)のための[レイアウトテンプレート](https://www.11ty.dev/docs/layouts/)を配置します。
101
+ Where [layout templates](https://www.11ty.dev/docs/layouts/) for [layout chaining](https://www.11ty.dev/docs/layout-chaining/) live.
102
102
 
103
- 具体的には[フロントマター](https://www.11ty.dev/docs/data-frontmatter/)あるいはエクスポートしたdataオブジェクトにてlayoutプロパティで指定するものを指します。
103
+ Specifically, the values referenced from a [frontmatter](https://www.11ty.dev/docs/data-frontmatter/) or an exported `data` object's `layout` property.
104
104
 
105
105
  ### src/\_includes/partials
106
106
 
107
- テンプレート内で呼び出すためのJSXコンポーネント/MDXテンプレートを配置します。
107
+ Where JSX and MDX partials called from templates live.
108
108
 
109
109
  ### src/public
110
110
 
111
- 静的アセットを配置します。distディレクトリ直下に出力されます。
111
+ Where static assets live. Copied to the root of `dist/`.
112
112
 
113
113
  ## Partial Hydration
114
114
 
115
- `.client.{js,jsx,ts,tsx}` という拡張子のファイルを `src` 配下に置くだけで、設定不要でパーシャルハイドレーションが有効になります。そのファイルは esbuild でバンドルされて `dist/**/*.client.js` に出力され、`<Island>` コンポーネントを通じて \<is-land> のクライアント側スクリプトとして読み込まれます。
115
+ Drop a file with the `.client.{js,jsx,ts,tsx}` sub-extension anywhere under `src/`, and Partial Hydration turns on with no extra configuration. That file is bundled with esbuild and emitted to `dist/**/*.client.js`, then loaded through the `<Island>` component as the client-side script of `<is-land>`.
116
116
 
117
- `clientComponent()` でマークしたコンポーネントを `<Island>` に渡すと、SSR 側の描画と、クライアント側のハイドレーションの両方に同じ props が流れます。
117
+ Pass a component marked with `clientComponent()` to `<Island>`, and the same props flow into both the SSR-side render and the client-side hydration.
118
118
 
119
119
  ```jsx
120
120
  // src/counter.client.jsx
121
121
  import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
122
- import { useState } from "preact/hooks";
122
+ import { useSignal } from "@preact/signals";
123
123
 
124
124
  function Counter(props) {
125
- const [n, setN] = useState(props.initial ?? 0);
126
- return <button onClick={() => setN(n + 1)}>{n}</button>;
125
+ const n = useSignal(props.initial ?? 0);
126
+ return <button onClick={() => n.value++}>{n}</button>;
127
127
  }
128
128
 
129
129
  export default clientComponent(Counter, import.meta.url);
@@ -134,31 +134,26 @@ export default clientComponent(Counter, import.meta.url);
134
134
  import { Island } from "@tuqulore-inc/eleventy-preset/island";
135
135
  import Counter from "./counter.client.jsx";
136
136
 
137
- <Island component={Counter} on="interaction" initial={5} />
137
+ <Island component={Counter} on="visible" initial={5} />
138
138
  ```
139
139
 
140
- 上の例では、`<Island>` が次のような \<is-land> 要素を SSR 出力します。
140
+ For the example above, `<Island>` emits an `<is-land>` element like this from SSR:
141
141
 
142
142
  ```html
143
- <is-land
144
- land-on:interaction
145
- type="preact"
146
- import="/counter.client.js"
147
- props='{"initial":5}'
148
- >
143
+ <is-land land-on:visible type="preact" import="/counter.client.js" props='{"initial":5}'>
149
144
  <button>5</button>
150
145
  </is-land>
151
146
  ```
152
147
 
153
- `on` prop は \<is-land> の初期化トリガー (`interaction` / `visible` / `idle`) に対応します。
148
+ The `on` prop maps to the `<is-land>` initialization trigger (`interaction` / `visible` / `idle`).
154
149
 
155
150
  > [!NOTE]
156
151
  >
157
- > [\<is-land>](https://github.com/11ty/is-land?tab=readme-ov-file#usage)の初期化条件を指定する属性は、デフォルトでは `on:*` の書式で指定する必要がありますが、JSX の書式と競合するので `land-on:*` に変更しています。パラメータ付きトリガー (例: `on:media("(min-width: ...)")`) を使う場合は `<Island>` ではなく素の \<is-land> を直接書いてください。
152
+ > The [`<is-land>`](https://github.com/11ty/is-land?tab=readme-ov-file#usage) initialization attribute normally uses the `on:*` form, but that conflicts with JSX syntax, so this preset uses `land-on:*` instead. For parameterized triggers such as `on:media("(min-width: ...)")`, drop `<Island>` and use the raw `<is-land>` element.
158
153
 
159
154
  ## Docker
160
155
 
161
- 以下のような手順で静的サイトを配信するDockerイメージを生成し、コンテナーを生成して動作させることができます。
156
+ To build and run a Docker image that serves the static site:
162
157
 
163
158
  ```
164
159
  docker build -t my-eleventy-site .
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
+ "sortImports": true,
4
+ "sortTailwindcss": true
5
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": ["typescript", "unicorn", "oxc", "react", "jsx-a11y", "import"],
4
+ "categories": {
5
+ "correctness": "error",
6
+ "suspicious": "warn",
7
+ "perf": "warn"
8
+ },
9
+ "env": {
10
+ "browser": true,
11
+ "es2024": true,
12
+ "node": true,
13
+ "serviceworker": true
14
+ },
15
+ "rules": {
16
+ "react/react-in-jsx-scope": "off",
17
+ "react/no-unknown-property": "off",
18
+ "no-underscore-dangle": "off"
19
+ },
20
+ "overrides": [
21
+ {
22
+ "files": ["**/*.cjs"],
23
+ "env": { "commonjs": true }
24
+ }
25
+ ],
26
+ "ignorePatterns": ["**/dist/**", "**/node_modules/**", "pnpm-lock.yaml", "**/*.mdx"]
27
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
- "recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
2
+ "recommendations": ["oxc.oxc-vscode"]
3
3
  }
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "extensions.ignoreRecommendations": false,
3
+ "editor.defaultFormatter": "oxc.oxc-vscode",
4
+ "editor.formatOnSave": false,
3
5
  "editor.codeActionsOnSave": {
4
- "source.fixAll.eslint": "explicit"
6
+ "source.format.oxc": "always",
7
+ "source.fixAll.oxc": "always"
5
8
  },
6
- "editor.defaultFormatter": "esbenp.prettier-vscode",
7
- "editor.formatOnSave": true,
8
9
  "css.validate": false,
9
10
  "less.validate": false,
10
11
  "scss.validate": false
@@ -7,34 +7,28 @@
7
7
  "build:eleventy": "dotenv -c production -- eleventy",
8
8
  "clean": "shx rm -rf dist",
9
9
  "dev": "dotenv -c development -- eleventy --serve",
10
- "format": "prettier --write .",
11
- "lint": "eslint --fix ."
10
+ "format": "oxfmt",
11
+ "lint": "oxlint --fix"
12
12
  },
13
13
  "dependencies": {
14
14
  "serve-handler": "^6.1.6"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@11ty/eleventy": "^3.1.2",
18
- "@eslint/js": "^10.0.0",
19
18
  "@iconify/json": "^2.2.90",
20
19
  "@iconify/tailwind4": "^1.0.6",
21
20
  "@jumpu-ui/tailwindcss": "3.0.1",
21
+ "@preact/signals": "^2.9.3",
22
22
  "@tailwindcss/postcss": "^4.0.14",
23
23
  "@tailwindcss/typography": "0.5.20",
24
- "@tuqulore-inc/eleventy-preset": "^5.0.1",
24
+ "@tuqulore-inc/eleventy-preset": "^5.2.0",
25
25
  "dotenv-cli": "^11.0.0",
26
- "eslint": "^10.0.0",
27
- "eslint-config-prettier": "^10.1.8",
28
- "eslint-plugin-mdx": "^3.2.0",
29
- "eslint-plugin-react": "^7.37.4",
30
- "globals": "^17.0.0",
31
26
  "npm-run-all2": "^9.0.0",
27
+ "oxfmt": "^0.60.0",
28
+ "oxlint": "^1.75.0",
32
29
  "postcss": "^8.5.6",
33
30
  "preact": "^10.26.4",
34
- "prettier": "^3.8.1",
35
- "prettier-plugin-tailwindcss": "^0.8.0",
36
31
  "shx": "^0.4.0",
37
- "slugify": "^1.6.6",
38
32
  "tailwind-merge": "^3.0.2",
39
33
  "tailwindcss": "^4.1.18"
40
34
  },
@@ -1,6 +1,7 @@
1
- import handler from "serve-handler";
2
1
  import http from "node:http";
3
2
 
3
+ import handler from "serve-handler";
4
+
4
5
  const server = http.createServer((request, response) => {
5
6
  return handler(request, response, {
6
7
  public: "dist",
@@ -1,26 +1,30 @@
1
+ import { useSignal, useSignalEffect } from "@preact/signals";
1
2
  import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
2
- import { useState, useRef, useEffect } from "preact/hooks";
3
- import slugify from "slugify";
3
+ import { useId, useRef } from "preact/hooks";
4
4
  import { twMerge } from "tailwind-merge";
5
5
 
6
6
  function MenuList(props) {
7
- const [open, setOpen] = useState(false);
8
- const [visible, setVisible] = useState(open);
9
- const handleTransitionStart = () => open && setVisible(true);
10
- const handleTransitionEnd = () => !open && setVisible(false);
7
+ const open = useSignal(false);
8
+ const visible = useSignal(open.value);
9
+ const handleTransitionStart = () => {
10
+ if (open.value) visible.value = true;
11
+ };
12
+ const handleTransitionEnd = () => {
13
+ if (!open.value) visible.value = false;
14
+ };
11
15
  const ref = useRef(null);
12
16
  const buttonRef = useRef(null);
13
- const slug = `${slugify(props.item.name)}-${props.index}`;
14
- useEffect(() => {
15
- if (!open) return;
17
+ const baseId = useId();
18
+ useSignalEffect(() => {
19
+ if (!open.value) return;
16
20
  const clickHandler = (e) => {
17
21
  if (ref.current?.contains(e.target)) return;
18
- setOpen(false);
22
+ open.value = false;
19
23
  };
20
24
  const keyHandler = (e) => {
21
25
  if (e.key !== "Escape") return;
22
26
  if (!ref.current?.contains(e.target)) return;
23
- setOpen(false);
27
+ open.value = false;
24
28
  buttonRef.current?.focus();
25
29
  };
26
30
  document.addEventListener("click", clickHandler);
@@ -29,34 +33,34 @@ function MenuList(props) {
29
33
  document.removeEventListener("click", clickHandler);
30
34
  document.removeEventListener("keydown", keyHandler);
31
35
  };
32
- }, [open]);
36
+ });
33
37
  return (
34
38
  <div
35
39
  ref={ref}
36
40
  onFocusOut={(e) => {
37
41
  if (ref.current?.contains(e.relatedTarget)) return;
38
- setOpen(false);
42
+ open.value = false;
39
43
  }}
40
44
  >
41
45
  <button
42
- id={`nav-button-${slug}`}
46
+ id={`nav-button-${baseId}`}
43
47
  ref={buttonRef}
44
- aria-controls={`nav-menu-${slug}`}
45
- aria-expanded={open}
48
+ aria-controls={`nav-menu-${baseId}`}
49
+ aria-expanded={open.value}
46
50
  class="jumpu-text-button"
47
51
  type="button"
48
- onClick={() => setOpen(!open)}
52
+ onClick={() => (open.value = !open.value)}
49
53
  >
50
54
  {props.item.name}
51
55
  </button>
52
56
  <ul
53
- id={`nav-menu-${slug}`}
54
- aria-labelledby={`nav-button-${slug}`}
57
+ id={`nav-menu-${baseId}`}
58
+ aria-labelledby={`nav-button-${baseId}`}
55
59
  class={twMerge(
56
60
  "jumpu-card absolute top-full left-1/2 max-h-[50vh] -translate-x-1/2 overflow-y-auto p-2",
57
61
  "translate-y-2 transition duration-75 ease-in-out",
58
- !open && "translate-y-[2.5%] scale-95 opacity-0",
59
- open || visible ? "visible" : "invisible",
62
+ !open.value && "translate-y-[2.5%] scale-95 opacity-0",
63
+ open.value || visible.value ? "visible" : "invisible",
60
64
  )}
61
65
  onTransitionStart={handleTransitionStart}
62
66
  onTransitionEnd={handleTransitionEnd}
@@ -71,16 +75,13 @@ function Desktop(props) {
71
75
  return (
72
76
  <nav class={props.class}>
73
77
  <ul class="flex items-center">
74
- {props.nav.map((item, itemIndex) =>
78
+ {props.nav.map((item) =>
75
79
  "children" in item ? (
76
- <li key={`${item.name}-${itemIndex}`} class="relative">
77
- <MenuList item={item} index={itemIndex}>
78
- {item.children.map((child, childIndex) => (
79
- <li key={`${child.name}-${childIndex}`}>
80
- <a
81
- class="jumpu-text-button w-full whitespace-nowrap"
82
- href={child.path}
83
- >
80
+ <li key={item.name} class="relative">
81
+ <MenuList item={item}>
82
+ {item.children.map((child) => (
83
+ <li key={child.name}>
84
+ <a class="jumpu-text-button w-full whitespace-nowrap" href={child.path}>
84
85
  {child.name}
85
86
  </a>
86
87
  </li>
@@ -88,7 +89,7 @@ function Desktop(props) {
88
89
  </MenuList>
89
90
  </li>
90
91
  ) : (
91
- <li key={`${item.name}-${itemIndex}`}>
92
+ <li key={item.name}>
92
93
  <a class="jumpu-text-button" href={item.path}>
93
94
  {item.name}
94
95
  </a>
@@ -1,20 +1,41 @@
1
+ import { useSignal, useSignalEffect } from "@preact/signals";
1
2
  import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
2
- import { useEffect, useRef, useState } from "preact/hooks";
3
+ import { useId, useRef } from "preact/hooks";
3
4
  import { twMerge } from "tailwind-merge";
4
5
 
6
+ function NavGroup(props) {
7
+ const groupId = useId();
8
+ return (
9
+ <div class="mb-6">
10
+ <p id={groupId} class="mb-2 ml-4 text-lg">
11
+ {props.item.name}
12
+ </p>
13
+ <ul aria-labelledby={groupId}>
14
+ {props.item.children.map((child) => (
15
+ <li key={child.name}>
16
+ <a class="jumpu-text-button block" href={child.path}>
17
+ {child.name}
18
+ </a>
19
+ </li>
20
+ ))}
21
+ </ul>
22
+ </div>
23
+ );
24
+ }
25
+
5
26
  function Mobile(props) {
6
- const [open, setOpen] = useState(false);
27
+ const open = useSignal(false);
7
28
  const openButtonRef = useRef(null);
8
29
  const closeButtonRef = useRef(null);
9
- useEffect(() => {
10
- if (!open) return;
30
+ useSignalEffect(() => {
31
+ if (!open.value) return;
11
32
  closeButtonRef.current?.focus();
12
33
  // NOTE: メニュー表示中は背景 (html) のスクロールを止め、モバイルで
13
34
  // メニューをスクロールしたつもりが背後のページも動く事故を防ぐ。
14
35
  document.documentElement.classList.add("overflow-hidden");
15
36
  const handler = (e) => {
16
37
  if (e.key !== "Escape") return;
17
- setOpen(false);
38
+ open.value = false;
18
39
  openButtonRef.current?.focus();
19
40
  };
20
41
  document.addEventListener("keydown", handler);
@@ -22,29 +43,29 @@ function Mobile(props) {
22
43
  document.removeEventListener("keydown", handler);
23
44
  document.documentElement.classList.remove("overflow-hidden");
24
45
  };
25
- }, [open]);
46
+ });
26
47
  return (
27
48
  <div class={props.class}>
28
49
  <button
29
50
  id="nav-button-mobile"
30
51
  ref={openButtonRef}
31
52
  aria-controls="nav-menu-mobile"
32
- aria-expanded={open}
33
- aria-label={open ? "Close navigation menu" : "Open navigation menu"}
53
+ aria-expanded={open.value}
54
+ aria-label={open.value ? "Close navigation menu" : "Open navigation menu"}
34
55
  class="jumpu-icon-button h-12 w-12 text-2xl"
35
56
  type="button"
36
- onClick={() => setOpen((v) => !v)}
57
+ onClick={() => (open.value = !open.value)}
37
58
  >
38
59
  <span class="icon-[material-symbols--menu]"></span>
39
60
  </button>
40
61
  <nav
41
62
  id="nav-menu-mobile"
42
63
  aria-label="Global navigation"
43
- inert={!open}
64
+ inert={!open.value}
44
65
  class={twMerge(
45
66
  "fixed top-0 left-0 h-screen w-screen overflow-y-auto overscroll-contain bg-white",
46
67
  "transition duration-150 ease-in-out",
47
- open ? "translate-x-0" : "translate-x-full",
68
+ open.value ? "translate-x-0" : "translate-x-full",
48
69
  )}
49
70
  >
50
71
  <button
@@ -53,31 +74,16 @@ function Mobile(props) {
53
74
  aria-label="Close navigation menu"
54
75
  type="button"
55
76
  onClick={() => {
56
- setOpen(false);
77
+ open.value = false;
57
78
  openButtonRef.current?.focus();
58
79
  }}
59
80
  >
60
81
  <span class="icon-[material-symbols--close]"></span>
61
82
  </button>
62
83
  <ul class="flex flex-col px-4 py-16">
63
- {props.nav.map((item, itemIndex) => (
64
- <li key={`${item.name}-${itemIndex}`}>
65
- {item.children && (
66
- <div class="mb-6" role="group" aria-label={item.name}>
67
- <p class="mb-2 ml-4 text-lg" aria-hidden="true">
68
- {item.name}
69
- </p>
70
- <ul>
71
- {item.children.map((child, childIndex) => (
72
- <li key={`${child.name}-${childIndex}`}>
73
- <a class="jumpu-text-button block" href={child.path}>
74
- {child.name}
75
- </a>
76
- </li>
77
- ))}
78
- </ul>
79
- </div>
80
- )}
84
+ {props.nav.map((item) => (
85
+ <li key={item.name}>
86
+ {item.children && <NavGroup item={item} />}
81
87
  {item.path && (
82
88
  <a class="jumpu-text-button block" href={item.path}>
83
89
  {item.name}
@@ -8,15 +8,10 @@ import Mobile from "./header/mobile.client.jsx";
8
8
  <a class="flex-shrink-0" href="/">
9
9
  {eleventy.site.name}
10
10
  </a>
11
- <Island
12
- component={Desktop}
13
- on="interaction"
14
- class="hidden md:block"
15
- nav={eleventy.nav}
16
- />
11
+ <Island component={Desktop} on="visible" class="hidden md:block" nav={eleventy.nav} />
17
12
  <Island
18
13
  component={Mobile}
19
- on="interaction"
14
+ on="visible"
20
15
  class="ml-auto flex items-center md:hidden"
21
16
  nav={eleventy.nav}
22
17
  />
@@ -1,23 +1,11 @@
1
1
  import { eleventy } from "@tuqulore-inc/eleventy-preset/eleventy";
2
2
 
3
- <meta
4
- name="description"
5
- content={eleventy.description ?? eleventy.site.description}
6
- />
7
- <meta
8
- property="og:description"
9
- content={eleventy.description ?? eleventy.site.description}
10
- />
3
+ <meta name="description" content={eleventy.description ?? eleventy.site.description} />
4
+ <meta property="og:description" content={eleventy.description ?? eleventy.site.description} />
11
5
  <meta property="og:site_name" content={eleventy.site.name} />
12
6
  <meta property="og:title" content={eleventy.title} />
13
7
  <meta property="og:type" content="website" />
14
- <meta
15
- property="og:url"
16
- content={new URL(eleventy.page.url, eleventy.site.url).href}
17
- />
18
- <meta
19
- property="og:image"
20
- content={new URL(eleventy.ogp ?? "/ogp.png", eleventy.site.url).href}
21
- />
8
+ <meta property="og:url" content={new URL(eleventy.page.url, eleventy.site.url).href} />
9
+ <meta property="og:image" content={new URL(eleventy.ogp ?? "/ogp.png", eleventy.site.url).href} />
22
10
  <meta property="og:image:alt" content={eleventy.title ?? eleventy.site.name} />
23
11
  <meta name="twitter:card" content="summary" />
@@ -1,7 +1,7 @@
1
- import { eleventy } from "@tuqulore-inc/eleventy-preset/eleventy";
1
+ ---
2
+ layout: base
3
+ ---
2
4
 
3
- export const data = {
4
- layout: "base",
5
- };
5
+ import { eleventy } from "@tuqulore-inc/eleventy-preset/eleventy";
6
6
 
7
7
  <article class="prose" dangerouslySetInnerHTML={{ __html: eleventy.content }} />
@@ -1,16 +1,12 @@
1
+ import { useSignal } from "@preact/signals";
1
2
  import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
2
- import { useState } from "preact/hooks";
3
3
 
4
4
  function Clicker() {
5
- const [counter, setCounter] = useState(0);
5
+ const counter = useSignal(0);
6
6
 
7
7
  return (
8
8
  <div class="flex items-center gap-4">
9
- <button
10
- type="button"
11
- class="jumpu-button"
12
- onClick={() => setCounter(counter + 1)}
13
- >
9
+ <button type="button" class="jumpu-button" onClick={() => counter.value++}>
14
10
  Count
15
11
  </button>
16
12
  <output class="text-xl tabular-nums">{counter}</output>
@@ -1,11 +1,11 @@
1
+ ---
2
+ layout: post
3
+ title: ようこそ
4
+ ---
5
+
1
6
  import { Island } from "@tuqulore-inc/eleventy-preset/island";
2
7
  import Clicker from "./clicker.client.jsx";
3
8
 
4
- export const data = {
5
- layout: "post",
6
- title: "ようこそ",
7
- };
8
-
9
9
  # ようこそ
10
10
 
11
11
  これは default テンプレートのスターターページです。`src/index.mdx` を編集して、実際のコンテンツに置き換えてください。
@@ -19,6 +19,6 @@ export const data = {
19
19
 
20
20
  ## Partial Hydration サンプル
21
21
 
22
- 以下のカウンターは Preact コンポーネントで、初回操作時にクライアント側でハイドレーションされます。
22
+ 以下のカウンターは Preact コンポーネントで、表示領域に入ったタイミングでクライアント側でハイドレーションされます。
23
23
 
24
- <Island component={Clicker} on="interaction" />
24
+ <Island component={Clicker} on="visible" />
@@ -1 +0,0 @@
1
- pnpm-lock.yaml
@@ -1,56 +0,0 @@
1
- import js from "@eslint/js";
2
- import prettier from "eslint-config-prettier/flat";
3
- import * as mdx from "eslint-plugin-mdx";
4
- import react from "eslint-plugin-react";
5
- import { defineConfig, globalIgnores } from "eslint/config";
6
- import globals from "globals";
7
-
8
- export default defineConfig([
9
- {
10
- files: ["**/*.{cjs,js,jsx}"],
11
- plugins: { js },
12
- extends: ["js/recommended"],
13
- },
14
- {
15
- files: ["**/*.cjs"],
16
- languageOptions: { sourceType: "commonjs" },
17
- },
18
- {
19
- files: ["**/*.{js,jsx}"],
20
- languageOptions: { sourceType: "module" },
21
- },
22
- {
23
- files: ["**/*.cjs", "*.js", "src/_data/**/*.js"],
24
- languageOptions: { globals: globals.node },
25
- },
26
- { ...react.configs.flat.recommended, files: ["**/*.{jsx,mdx}"] },
27
- {
28
- files: ["**/*.{jsx,mdx}"],
29
- plugins: { react },
30
- languageOptions: {
31
- parserOptions: {
32
- ecmaFeatures: { jsx: true },
33
- },
34
- globals: {
35
- ...globals.serviceworker,
36
- ...globals.browser,
37
- },
38
- },
39
- settings: {
40
- // NOTE: 本テンプレートは Preact 処理系だが、eslint-plugin-react の
41
- // JSX 構文ルール (jsx-key など) を流用したい。version 未指定だと
42
- // "React version not specified" 警告が出るので、Preact 10 の JSX
43
- // runtime が API 互換な React 18 系をスタブとして与えて抑制する。
44
- react: { version: "18.3.0" },
45
- },
46
- rules: {
47
- "react/jsx-uses-react": "off",
48
- "react/react-in-jsx-scope": "off",
49
- "react/prop-types": "off",
50
- "react/no-unknown-property": "off",
51
- },
52
- },
53
- mdx.flat,
54
- globalIgnores(["dist/"]),
55
- prettier,
56
- ]);
@@ -1,4 +0,0 @@
1
- /** @type {import("prettier").Config} */
2
- export default {
3
- plugins: ["prettier-plugin-tailwindcss"],
4
- };