@tuqulore-inc/create-eleventy 5.0.0 → 5.1.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 +13 -13
- package/package.json +3 -3
- package/templates/default/Dockerfile +1 -2
- package/templates/default/README.md +44 -44
- package/templates/default/eslint.config.js +8 -1
- package/templates/default/package.json +2 -1
- package/templates/default/src/__data/nav.json +6 -9
- package/templates/default/src/__data/site.js +6 -0
- package/templates/default/src/__includes/base.mdx +11 -4
- package/templates/default/src/__includes/partials/header/desktop.client.jsx +48 -24
- package/templates/default/src/__includes/partials/header/mobile.client.jsx +45 -27
- package/templates/default/src/__includes/partials/ogp.mdx +8 -3
- package/templates/default/src/clicker.client.jsx +9 -5
- package/templates/default/src/index.mdx +11 -6
- package/templates/default/src/main.css +11 -0
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
# @tuqulore-inc/create-eleventy
|
|
2
2
|
|
|
3
|
-
Eleventy + Preact +
|
|
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`
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuqulore-inc/create-eleventy",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Create a new Eleventy project with Preact and TailwindCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"create",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "node --test"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tuqulore-inc/eslint-config": "5.
|
|
31
|
+
"@tuqulore-inc/eslint-config": "5.1.0",
|
|
32
32
|
"eslint": "^10.0.0"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "0d43e2a32a951ca608a2c5095c084737b7f3c8bf"
|
|
41
41
|
}
|
|
@@ -5,14 +5,13 @@ RUN corepack enable
|
|
|
5
5
|
RUN pnpm install --frozen-lockfile
|
|
6
6
|
COPY postcss.config.js eleventy.config.js .env* ./
|
|
7
7
|
COPY src/ ./src
|
|
8
|
-
COPY lib/ ./lib
|
|
9
8
|
RUN pnpm build
|
|
10
9
|
|
|
11
10
|
FROM node:24-slim@sha256:cb4e8f7c443347358b7875e717c29e27bf9befc8f5a26cf18af3c3dec80e58c5 as install
|
|
12
11
|
WORKDIR /app
|
|
13
12
|
COPY package.json pnpm-lock.yaml ./
|
|
14
13
|
RUN corepack enable
|
|
15
|
-
RUN pnpm install --frozen-lockfile
|
|
14
|
+
RUN pnpm install --frozen-lockfile --prod
|
|
16
15
|
|
|
17
16
|
FROM gcr.io/distroless/nodejs24-debian13@sha256:ac0daf5d207757b275f3df0de9b296675500e773cc447c65afd66a948d5bf013
|
|
18
17
|
WORKDIR /app
|
|
@@ -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
|
-
>
|
|
12
|
+
> Install [pnpm](https://pnpm.io/installation) first.
|
|
13
13
|
|
|
14
14
|
```shell
|
|
15
|
-
pnpm install #
|
|
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 |
|
|
31
|
+
| Name | Description |
|
|
32
|
+
| :------- | :-------------------------------------------------------- |
|
|
33
|
+
| SITE_URL | The URL of the site built from this repository. Required. |
|
|
34
34
|
|
|
35
|
-
###
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
|
61
|
+
Renders JSX templates into HTML with dynamic behavior.
|
|
62
62
|
|
|
63
63
|
### [Tailwind CSS](https://tailwindcss.com/)
|
|
64
64
|
|
|
65
|
-
|
|
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
|
-
[
|
|
97
|
+
Where [global data](https://www.11ty.dev/docs/data-global/) lives.
|
|
98
98
|
|
|
99
99
|
### src/\_includes
|
|
100
100
|
|
|
101
|
-
[
|
|
101
|
+
Where [layout templates](https://www.11ty.dev/docs/layouts/) for [layout chaining](https://www.11ty.dev/docs/layout-chaining/) live.
|
|
102
102
|
|
|
103
|
-
|
|
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
|
-
|
|
107
|
+
Where JSX and MDX partials called from templates live.
|
|
108
108
|
|
|
109
109
|
### src/public
|
|
110
110
|
|
|
111
|
-
|
|
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}`
|
|
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()`
|
|
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 {
|
|
122
|
+
import { useSignal } from "@preact/signals";
|
|
123
123
|
|
|
124
124
|
function Counter(props) {
|
|
125
|
-
const
|
|
126
|
-
return <button onClick={() =>
|
|
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);
|
|
@@ -137,7 +137,7 @@ import Counter from "./counter.client.jsx";
|
|
|
137
137
|
<Island component={Counter} on="interaction" initial={5} />
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
For the example above, `<Island>` emits an `<is-land>` element like this from SSR:
|
|
141
141
|
|
|
142
142
|
```html
|
|
143
143
|
<is-land
|
|
@@ -150,15 +150,15 @@ import Counter from "./counter.client.jsx";
|
|
|
150
150
|
</is-land>
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
`on` prop
|
|
153
|
+
The `on` prop maps to the `<is-land>` initialization trigger (`interaction` / `visible` / `idle`).
|
|
154
154
|
|
|
155
155
|
> [!NOTE]
|
|
156
156
|
>
|
|
157
|
-
> [
|
|
157
|
+
> 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
158
|
|
|
159
159
|
## Docker
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
To build and run a Docker image that serves the static site:
|
|
162
162
|
|
|
163
163
|
```
|
|
164
164
|
docker build -t my-eleventy-site .
|
|
@@ -23,7 +23,7 @@ export default defineConfig([
|
|
|
23
23
|
files: ["**/*.cjs", "*.js", "src/_data/**/*.js"],
|
|
24
24
|
languageOptions: { globals: globals.node },
|
|
25
25
|
},
|
|
26
|
-
react.configs.flat.recommended,
|
|
26
|
+
{ ...react.configs.flat.recommended, files: ["**/*.{jsx,mdx}"] },
|
|
27
27
|
{
|
|
28
28
|
files: ["**/*.{jsx,mdx}"],
|
|
29
29
|
plugins: { react },
|
|
@@ -36,6 +36,13 @@ export default defineConfig([
|
|
|
36
36
|
...globals.browser,
|
|
37
37
|
},
|
|
38
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
|
+
},
|
|
39
46
|
rules: {
|
|
40
47
|
"react/jsx-uses-react": "off",
|
|
41
48
|
"react/react-in-jsx-scope": "off",
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"@iconify/json": "^2.2.90",
|
|
20
20
|
"@iconify/tailwind4": "^1.0.6",
|
|
21
21
|
"@jumpu-ui/tailwindcss": "3.0.1",
|
|
22
|
+
"@preact/signals": "^2.9.3",
|
|
22
23
|
"@tailwindcss/postcss": "^4.0.14",
|
|
23
24
|
"@tailwindcss/typography": "0.5.20",
|
|
24
|
-
"@tuqulore-inc/eleventy-preset": "^5.
|
|
25
|
+
"@tuqulore-inc/eleventy-preset": "^5.1.0",
|
|
25
26
|
"dotenv-cli": "^11.0.0",
|
|
26
27
|
"eslint": "^10.0.0",
|
|
27
28
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"name": "Group
|
|
3
|
+
"name": "Group A",
|
|
4
4
|
"children": [
|
|
5
|
-
{ "name": "
|
|
6
|
-
{ "name": "
|
|
7
|
-
{ "name": "
|
|
8
|
-
{ "name": "Menu", "path": "/" },
|
|
9
|
-
{ "name": "Menu", "path": "/" },
|
|
10
|
-
{ "name": "Menu", "path": "/" }
|
|
5
|
+
{ "name": "Item A-1", "path": "/" },
|
|
6
|
+
{ "name": "Item A-2", "path": "/" },
|
|
7
|
+
{ "name": "Item A-3", "path": "/" }
|
|
11
8
|
]
|
|
12
9
|
},
|
|
13
|
-
{ "name": "
|
|
14
|
-
{ "name": "
|
|
10
|
+
{ "name": "Item B", "path": "/" },
|
|
11
|
+
{ "name": "Item C", "path": "/" }
|
|
15
12
|
]
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
if (!process.env.SITE_URL) {
|
|
2
|
+
throw new Error(
|
|
3
|
+
"SITE_URL is not set. Define it in .env (or the appropriate .env.{development,production}[.local]) so canonical/OGP URLs can be built.",
|
|
4
|
+
);
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export default {
|
|
2
8
|
description: "Site Description",
|
|
3
9
|
name: "Site Name",
|
|
@@ -7,19 +7,26 @@ import Footer from "./partials/footer.mdx";
|
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="utf-8" />
|
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
10
|
-
<Ogp />
|
|
11
|
-
<link rel="stylesheet" href="/main.css" />
|
|
12
10
|
<title>
|
|
13
11
|
{eleventy.title && `${eleventy.title} | `}
|
|
14
12
|
{eleventy.site.name}
|
|
15
13
|
</title>
|
|
14
|
+
<Ogp />
|
|
15
|
+
<link rel="stylesheet" href="/main.css" />
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
18
|
+
<a
|
|
19
|
+
href="#main"
|
|
20
|
+
class="jumpu-button sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50"
|
|
21
|
+
>
|
|
22
|
+
本文へスキップ
|
|
23
|
+
</a>
|
|
18
24
|
<Header />
|
|
19
|
-
<
|
|
25
|
+
<main
|
|
26
|
+
id="main"
|
|
20
27
|
class="mx-auto mb-4 min-h-[60vh] max-w-6xl px-4"
|
|
21
28
|
dangerouslySetInnerHTML={{ __html: eleventy.content }}
|
|
22
|
-
></
|
|
29
|
+
></main>
|
|
23
30
|
<Footer />
|
|
24
31
|
</body>
|
|
25
32
|
</html>
|
|
@@ -1,43 +1,67 @@
|
|
|
1
1
|
import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
|
|
2
|
-
import {
|
|
2
|
+
import { useSignal, useSignalEffect } from "@preact/signals";
|
|
3
|
+
import { useRef } from "preact/hooks";
|
|
3
4
|
import slugify from "slugify";
|
|
4
5
|
import { twMerge } from "tailwind-merge";
|
|
5
6
|
|
|
6
7
|
function MenuList(props) {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const handleTransitionStart = () =>
|
|
10
|
-
|
|
8
|
+
const open = useSignal(false);
|
|
9
|
+
const visible = useSignal(open.value);
|
|
10
|
+
const handleTransitionStart = () => {
|
|
11
|
+
if (open.value) visible.value = true;
|
|
12
|
+
};
|
|
13
|
+
const handleTransitionEnd = () => {
|
|
14
|
+
if (!open.value) visible.value = false;
|
|
15
|
+
};
|
|
11
16
|
const ref = useRef(null);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const buttonRef = useRef(null);
|
|
18
|
+
const slug = `${slugify(props.item.name)}-${props.index}`;
|
|
19
|
+
useSignalEffect(() => {
|
|
20
|
+
if (!open.value) return;
|
|
21
|
+
const clickHandler = (e) => {
|
|
22
|
+
if (ref.current?.contains(e.target)) return;
|
|
23
|
+
open.value = false;
|
|
16
24
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const keyHandler = (e) => {
|
|
26
|
+
if (e.key !== "Escape") return;
|
|
27
|
+
if (!ref.current?.contains(e.target)) return;
|
|
28
|
+
open.value = false;
|
|
29
|
+
buttonRef.current?.focus();
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener("click", clickHandler);
|
|
32
|
+
document.addEventListener("keydown", keyHandler);
|
|
33
|
+
return () => {
|
|
34
|
+
document.removeEventListener("click", clickHandler);
|
|
35
|
+
document.removeEventListener("keydown", keyHandler);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
20
38
|
return (
|
|
21
|
-
<div
|
|
39
|
+
<div
|
|
40
|
+
ref={ref}
|
|
41
|
+
onFocusOut={(e) => {
|
|
42
|
+
if (ref.current?.contains(e.relatedTarget)) return;
|
|
43
|
+
open.value = false;
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
22
46
|
<button
|
|
23
|
-
id={`nav-button-${
|
|
24
|
-
|
|
25
|
-
aria-controls={`nav-menu-${
|
|
47
|
+
id={`nav-button-${slug}`}
|
|
48
|
+
ref={buttonRef}
|
|
49
|
+
aria-controls={`nav-menu-${slug}`}
|
|
50
|
+
aria-expanded={open.value}
|
|
26
51
|
class="jumpu-text-button"
|
|
27
52
|
type="button"
|
|
28
|
-
onClick={() =>
|
|
53
|
+
onClick={() => (open.value = !open.value)}
|
|
29
54
|
>
|
|
30
55
|
{props.item.name}
|
|
31
56
|
</button>
|
|
32
57
|
<ul
|
|
33
|
-
id={`nav-menu-${
|
|
34
|
-
|
|
35
|
-
aria-labelledby={`nav-button-${slugify(props.item.name)}`}
|
|
58
|
+
id={`nav-menu-${slug}`}
|
|
59
|
+
aria-labelledby={`nav-button-${slug}`}
|
|
36
60
|
class={twMerge(
|
|
37
61
|
"jumpu-card absolute top-full left-1/2 max-h-[50vh] -translate-x-1/2 overflow-y-auto p-2",
|
|
38
62
|
"translate-y-2 transition duration-75 ease-in-out",
|
|
39
|
-
!open && "translate-y-[2.5%] scale-95 opacity-0",
|
|
40
|
-
open || visible ? "visible" : "invisible",
|
|
63
|
+
!open.value && "translate-y-[2.5%] scale-95 opacity-0",
|
|
64
|
+
open.value || visible.value ? "visible" : "invisible",
|
|
41
65
|
)}
|
|
42
66
|
onTransitionStart={handleTransitionStart}
|
|
43
67
|
onTransitionEnd={handleTransitionEnd}
|
|
@@ -55,9 +79,9 @@ function Desktop(props) {
|
|
|
55
79
|
{props.nav.map((item, itemIndex) =>
|
|
56
80
|
"children" in item ? (
|
|
57
81
|
<li key={`${item.name}-${itemIndex}`} class="relative">
|
|
58
|
-
<MenuList item={item}>
|
|
82
|
+
<MenuList item={item} index={itemIndex}>
|
|
59
83
|
{item.children.map((child, childIndex) => (
|
|
60
|
-
<li key={`${child.name}-${childIndex}`}
|
|
84
|
+
<li key={`${child.name}-${childIndex}`}>
|
|
61
85
|
<a
|
|
62
86
|
class="jumpu-text-button w-full whitespace-nowrap"
|
|
63
87
|
href={child.path}
|
|
@@ -1,57 +1,75 @@
|
|
|
1
1
|
import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
|
|
2
|
-
import {
|
|
2
|
+
import { useSignal, useSignalEffect } from "@preact/signals";
|
|
3
|
+
import { useRef } from "preact/hooks";
|
|
3
4
|
import { twMerge } from "tailwind-merge";
|
|
4
5
|
|
|
5
6
|
function Mobile(props) {
|
|
6
|
-
const
|
|
7
|
+
const open = useSignal(false);
|
|
8
|
+
const openButtonRef = useRef(null);
|
|
9
|
+
const closeButtonRef = useRef(null);
|
|
10
|
+
useSignalEffect(() => {
|
|
11
|
+
if (!open.value) return;
|
|
12
|
+
closeButtonRef.current?.focus();
|
|
13
|
+
// NOTE: メニュー表示中は背景 (html) のスクロールを止め、モバイルで
|
|
14
|
+
// メニューをスクロールしたつもりが背後のページも動く事故を防ぐ。
|
|
15
|
+
document.documentElement.classList.add("overflow-hidden");
|
|
16
|
+
const handler = (e) => {
|
|
17
|
+
if (e.key !== "Escape") return;
|
|
18
|
+
open.value = false;
|
|
19
|
+
openButtonRef.current?.focus();
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener("keydown", handler);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener("keydown", handler);
|
|
24
|
+
document.documentElement.classList.remove("overflow-hidden");
|
|
25
|
+
};
|
|
26
|
+
});
|
|
7
27
|
return (
|
|
8
28
|
<div class={props.class}>
|
|
9
29
|
<button
|
|
10
30
|
id="nav-button-mobile"
|
|
31
|
+
ref={openButtonRef}
|
|
11
32
|
aria-controls="nav-menu-mobile"
|
|
12
|
-
aria-
|
|
13
|
-
|
|
33
|
+
aria-expanded={open.value}
|
|
34
|
+
aria-label={
|
|
35
|
+
open.value ? "Close navigation menu" : "Open navigation menu"
|
|
36
|
+
}
|
|
37
|
+
class="jumpu-icon-button h-12 w-12 text-2xl"
|
|
14
38
|
type="button"
|
|
15
|
-
onClick={() =>
|
|
39
|
+
onClick={() => (open.value = !open.value)}
|
|
16
40
|
>
|
|
17
41
|
<span class="icon-[material-symbols--menu]"></span>
|
|
18
|
-
<span
|
|
19
|
-
id="nav-tooltip-mobile"
|
|
20
|
-
role="tooltip"
|
|
21
|
-
class="![transform:translate(-50%,_225%)_scale(0)] group-hover:![transform:translate(-50%,_225%)_scale(1)]"
|
|
22
|
-
>
|
|
23
|
-
Menu
|
|
24
|
-
</span>
|
|
25
42
|
</button>
|
|
26
43
|
<nav
|
|
27
44
|
id="nav-menu-mobile"
|
|
45
|
+
aria-label="Global navigation"
|
|
46
|
+
inert={!open.value}
|
|
28
47
|
class={twMerge(
|
|
29
|
-
"fixed top-0 left-0 h-screen w-screen overflow-y-auto bg-white",
|
|
48
|
+
"fixed top-0 left-0 h-screen w-screen overflow-y-auto overscroll-contain bg-white",
|
|
30
49
|
"transition duration-150 ease-in-out",
|
|
31
|
-
open ? "translate-x-0" : "translate-x-full",
|
|
50
|
+
open.value ? "translate-x-0" : "translate-x-full",
|
|
32
51
|
)}
|
|
33
52
|
>
|
|
34
53
|
<button
|
|
35
|
-
|
|
36
|
-
|
|
54
|
+
ref={closeButtonRef}
|
|
55
|
+
class="jumpu-icon-button fixed top-2 right-4 h-12 w-12 text-2xl"
|
|
56
|
+
aria-label="Close navigation menu"
|
|
37
57
|
type="button"
|
|
38
|
-
onClick={() =>
|
|
58
|
+
onClick={() => {
|
|
59
|
+
open.value = false;
|
|
60
|
+
openButtonRef.current?.focus();
|
|
61
|
+
}}
|
|
39
62
|
>
|
|
40
63
|
<span class="icon-[material-symbols--close]"></span>
|
|
41
|
-
<span
|
|
42
|
-
id="nav-tooltip-close"
|
|
43
|
-
role="tooltip"
|
|
44
|
-
class="![transform:translate(-50%,_225%)_scale(0)] group-hover:![transform:translate(-50%,_225%)_scale(1)]"
|
|
45
|
-
>
|
|
46
|
-
Close
|
|
47
|
-
</span>
|
|
48
64
|
</button>
|
|
49
65
|
<ul class="flex flex-col px-4 py-16">
|
|
50
66
|
{props.nav.map((item, itemIndex) => (
|
|
51
67
|
<li key={`${item.name}-${itemIndex}`}>
|
|
52
68
|
{item.children && (
|
|
53
|
-
<
|
|
54
|
-
<
|
|
69
|
+
<div class="mb-6" role="group" aria-label={item.name}>
|
|
70
|
+
<p class="mb-2 ml-4 text-lg" aria-hidden="true">
|
|
71
|
+
{item.name}
|
|
72
|
+
</p>
|
|
55
73
|
<ul>
|
|
56
74
|
{item.children.map((child, childIndex) => (
|
|
57
75
|
<li key={`${child.name}-${childIndex}`}>
|
|
@@ -61,7 +79,7 @@ function Mobile(props) {
|
|
|
61
79
|
</li>
|
|
62
80
|
))}
|
|
63
81
|
</ul>
|
|
64
|
-
</
|
|
82
|
+
</div>
|
|
65
83
|
)}
|
|
66
84
|
{item.path && (
|
|
67
85
|
<a class="jumpu-text-button block" href={item.path}>
|
|
@@ -1,5 +1,9 @@
|
|
|
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
|
+
/>
|
|
3
7
|
<meta
|
|
4
8
|
property="og:description"
|
|
5
9
|
content={eleventy.description ?? eleventy.site.description}
|
|
@@ -9,10 +13,11 @@ import { eleventy } from "@tuqulore-inc/eleventy-preset/eleventy";
|
|
|
9
13
|
<meta property="og:type" content="website" />
|
|
10
14
|
<meta
|
|
11
15
|
property="og:url"
|
|
12
|
-
content={new URL(eleventy.
|
|
16
|
+
content={new URL(eleventy.page.url, eleventy.site.url).href}
|
|
13
17
|
/>
|
|
14
18
|
<meta
|
|
15
19
|
property="og:image"
|
|
16
|
-
content={new URL(eleventy.
|
|
20
|
+
content={new URL(eleventy.ogp ?? "/ogp.png", eleventy.site.url).href}
|
|
17
21
|
/>
|
|
18
|
-
<meta property="
|
|
22
|
+
<meta property="og:image:alt" content={eleventy.title ?? eleventy.site.name} />
|
|
23
|
+
<meta name="twitter:card" content="summary" />
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
|
|
2
|
-
import {
|
|
2
|
+
import { useSignal } from "@preact/signals";
|
|
3
3
|
|
|
4
4
|
function Clicker() {
|
|
5
|
-
const
|
|
5
|
+
const counter = useSignal(0);
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
|
-
<div>
|
|
9
|
-
<button
|
|
8
|
+
<div class="flex items-center gap-4">
|
|
9
|
+
<button
|
|
10
|
+
type="button"
|
|
11
|
+
class="jumpu-button"
|
|
12
|
+
onClick={() => counter.value++}
|
|
13
|
+
>
|
|
10
14
|
Count
|
|
11
15
|
</button>
|
|
12
|
-
<
|
|
16
|
+
<output class="text-xl tabular-nums">{counter}</output>
|
|
13
17
|
</div>
|
|
14
18
|
);
|
|
15
19
|
}
|
|
@@ -3,17 +3,22 @@ import Clicker from "./clicker.client.jsx";
|
|
|
3
3
|
|
|
4
4
|
export const data = {
|
|
5
5
|
layout: "post",
|
|
6
|
-
title: "
|
|
6
|
+
title: "ようこそ",
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# ようこそ
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
これは default テンプレートのスターターページです。`src/index.mdx` を編集して、実際のコンテンツに置き換えてください。
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## 含まれているもの
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
- Eleventy + Preact + Tailwind CSS
|
|
16
|
+
- MDX で書けるレイアウト・ページ
|
|
17
|
+
- `.client.jsx` 命名によるパーシャルハイドレーション
|
|
18
|
+
- Tailwind Typography による Markdown スタイル
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
## Partial Hydration サンプル
|
|
21
|
+
|
|
22
|
+
以下のカウンターは Preact コンポーネントで、初回操作時にクライアント側でハイドレーションされます。
|
|
18
23
|
|
|
19
24
|
<Island component={Clicker} on="interaction" />
|