@tuqulore-inc/create-eleventy 5.0.0 → 5.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuqulore-inc/create-eleventy",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
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.0.0",
31
+ "@tuqulore-inc/eslint-config": "5.0.1",
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": "155e0c2ad43c00e4611d5069362af07db71bf5f9"
40
+ "gitHead": "5966820d0ada95a8b172a8c0890150d8b1a3a543"
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
@@ -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",
@@ -21,7 +21,7 @@
21
21
  "@jumpu-ui/tailwindcss": "3.0.1",
22
22
  "@tailwindcss/postcss": "^4.0.14",
23
23
  "@tailwindcss/typography": "0.5.20",
24
- "@tuqulore-inc/eleventy-preset": "^5.0.0",
24
+ "@tuqulore-inc/eleventy-preset": "^5.0.1",
25
25
  "dotenv-cli": "^11.0.0",
26
26
  "eslint": "^10.0.0",
27
27
  "eslint-config-prettier": "^10.1.8",
@@ -1,15 +1,12 @@
1
1
  [
2
2
  {
3
- "name": "Group Menu",
3
+ "name": "Group A",
4
4
  "children": [
5
- { "name": "Menu", "path": "/" },
6
- { "name": "Menu", "path": "/" },
7
- { "name": "Menu", "path": "/" },
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": "Menu", "path": "/" },
14
- { "name": "Menu", "path": "/" }
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
- <div
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
- ></div>
29
+ ></main>
23
30
  <Footer />
24
31
  </body>
25
32
  </html>
@@ -9,20 +9,40 @@ function MenuList(props) {
9
9
  const handleTransitionStart = () => open && setVisible(true);
10
10
  const handleTransitionEnd = () => !open && setVisible(false);
11
11
  const ref = useRef(null);
12
+ const buttonRef = useRef(null);
13
+ const slug = `${slugify(props.item.name)}-${props.index}`;
12
14
  useEffect(() => {
13
- const handler = (e) => {
14
- if (!ref.current || ref.current.contains(e.target)) return;
15
+ if (!open) return;
16
+ const clickHandler = (e) => {
17
+ if (ref.current?.contains(e.target)) return;
15
18
  setOpen(false);
16
19
  };
17
- document.addEventListener("click", handler);
18
- return () => document.removeEventListener("click", handler);
19
- }, [ref.current, setOpen]);
20
+ const keyHandler = (e) => {
21
+ if (e.key !== "Escape") return;
22
+ if (!ref.current?.contains(e.target)) return;
23
+ setOpen(false);
24
+ buttonRef.current?.focus();
25
+ };
26
+ document.addEventListener("click", clickHandler);
27
+ document.addEventListener("keydown", keyHandler);
28
+ return () => {
29
+ document.removeEventListener("click", clickHandler);
30
+ document.removeEventListener("keydown", keyHandler);
31
+ };
32
+ }, [open]);
20
33
  return (
21
- <div role="presentation" ref={ref}>
34
+ <div
35
+ ref={ref}
36
+ onFocusOut={(e) => {
37
+ if (ref.current?.contains(e.relatedTarget)) return;
38
+ setOpen(false);
39
+ }}
40
+ >
22
41
  <button
23
- id={`nav-button-${slugify(props.item.name)}`}
24
- aria-haspopup="menu"
25
- aria-controls={`nav-menu-${slugify(props.item.name)}`}
42
+ id={`nav-button-${slug}`}
43
+ ref={buttonRef}
44
+ aria-controls={`nav-menu-${slug}`}
45
+ aria-expanded={open}
26
46
  class="jumpu-text-button"
27
47
  type="button"
28
48
  onClick={() => setOpen(!open)}
@@ -30,9 +50,8 @@ function MenuList(props) {
30
50
  {props.item.name}
31
51
  </button>
32
52
  <ul
33
- id={`nav-menu-${slugify(props.item.name)}`}
34
- role="menu"
35
- aria-labelledby={`nav-button-${slugify(props.item.name)}`}
53
+ id={`nav-menu-${slug}`}
54
+ aria-labelledby={`nav-button-${slug}`}
36
55
  class={twMerge(
37
56
  "jumpu-card absolute top-full left-1/2 max-h-[50vh] -translate-x-1/2 overflow-y-auto p-2",
38
57
  "translate-y-2 transition duration-75 ease-in-out",
@@ -55,9 +74,9 @@ function Desktop(props) {
55
74
  {props.nav.map((item, itemIndex) =>
56
75
  "children" in item ? (
57
76
  <li key={`${item.name}-${itemIndex}`} class="relative">
58
- <MenuList item={item}>
77
+ <MenuList item={item} index={itemIndex}>
59
78
  {item.children.map((child, childIndex) => (
60
- <li key={`${child.name}-${childIndex}`} role="menuitem">
79
+ <li key={`${child.name}-${childIndex}`}>
61
80
  <a
62
81
  class="jumpu-text-button w-full whitespace-nowrap"
63
82
  href={child.path}
@@ -1,57 +1,72 @@
1
1
  import { clientComponent } from "@tuqulore-inc/eleventy-preset/island";
2
- import { useState } from "preact/hooks";
2
+ import { useEffect, useRef, useState } from "preact/hooks";
3
3
  import { twMerge } from "tailwind-merge";
4
4
 
5
5
  function Mobile(props) {
6
6
  const [open, setOpen] = useState(false);
7
+ const openButtonRef = useRef(null);
8
+ const closeButtonRef = useRef(null);
9
+ useEffect(() => {
10
+ if (!open) return;
11
+ closeButtonRef.current?.focus();
12
+ // NOTE: メニュー表示中は背景 (html) のスクロールを止め、モバイルで
13
+ // メニューをスクロールしたつもりが背後のページも動く事故を防ぐ。
14
+ document.documentElement.classList.add("overflow-hidden");
15
+ const handler = (e) => {
16
+ if (e.key !== "Escape") return;
17
+ setOpen(false);
18
+ openButtonRef.current?.focus();
19
+ };
20
+ document.addEventListener("keydown", handler);
21
+ return () => {
22
+ document.removeEventListener("keydown", handler);
23
+ document.documentElement.classList.remove("overflow-hidden");
24
+ };
25
+ }, [open]);
7
26
  return (
8
27
  <div class={props.class}>
9
28
  <button
10
29
  id="nav-button-mobile"
30
+ ref={openButtonRef}
11
31
  aria-controls="nav-menu-mobile"
12
- aria-describedby="nav-tooltip-mobile"
13
- class="jumpu-icon-button group h-12 w-12 text-2xl"
32
+ aria-expanded={open}
33
+ aria-label={open ? "Close navigation menu" : "Open navigation menu"}
34
+ class="jumpu-icon-button h-12 w-12 text-2xl"
14
35
  type="button"
15
- onClick={() => setOpen(true)}
36
+ onClick={() => setOpen((v) => !v)}
16
37
  >
17
38
  <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
39
  </button>
26
40
  <nav
27
41
  id="nav-menu-mobile"
42
+ aria-label="Global navigation"
43
+ inert={!open}
28
44
  class={twMerge(
29
- "fixed top-0 left-0 h-screen w-screen overflow-y-auto bg-white",
45
+ "fixed top-0 left-0 h-screen w-screen overflow-y-auto overscroll-contain bg-white",
30
46
  "transition duration-150 ease-in-out",
31
47
  open ? "translate-x-0" : "translate-x-full",
32
48
  )}
33
49
  >
34
50
  <button
35
- class="jumpu-icon-button group fixed top-2 right-4 h-12 w-12 text-2xl"
36
- aria-describedby="nav-tooltip-close"
51
+ ref={closeButtonRef}
52
+ class="jumpu-icon-button fixed top-2 right-4 h-12 w-12 text-2xl"
53
+ aria-label="Close navigation menu"
37
54
  type="button"
38
- onClick={() => setOpen(false)}
55
+ onClick={() => {
56
+ setOpen(false);
57
+ openButtonRef.current?.focus();
58
+ }}
39
59
  >
40
60
  <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
61
  </button>
49
62
  <ul class="flex flex-col px-4 py-16">
50
63
  {props.nav.map((item, itemIndex) => (
51
64
  <li key={`${item.name}-${itemIndex}`}>
52
65
  {item.children && (
53
- <section class="mb-6">
54
- <h2 class="mb-2 ml-4 text-lg">{item.name}</h2>
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>
55
70
  <ul>
56
71
  {item.children.map((child, childIndex) => (
57
72
  <li key={`${child.name}-${childIndex}`}>
@@ -61,7 +76,7 @@ function Mobile(props) {
61
76
  </li>
62
77
  ))}
63
78
  </ul>
64
- </section>
79
+ </div>
65
80
  )}
66
81
  {item.path && (
67
82
  <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.site.url).origin.concat(eleventy.page.url)}
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.site.url).origin.concat(eleventy.ogp ?? "ogp.png")}
20
+ content={new URL(eleventy.ogp ?? "/ogp.png", eleventy.site.url).href}
17
21
  />
18
- <meta property="twitter:card" content="summary" />
22
+ <meta property="og:image:alt" content={eleventy.title ?? eleventy.site.name} />
23
+ <meta name="twitter:card" content="summary" />
@@ -5,11 +5,15 @@ function Clicker() {
5
5
  const [counter, setCounter] = useState(0);
6
6
 
7
7
  return (
8
- <div>
9
- <button class="jumpu-button" onClick={() => setCounter(counter + 1)}>
8
+ <div class="flex items-center gap-4">
9
+ <button
10
+ type="button"
11
+ class="jumpu-button"
12
+ onClick={() => setCounter(counter + 1)}
13
+ >
10
14
  Count
11
15
  </button>
12
- <p>{counter}</p>
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: "Hello World",
6
+ title: "ようこそ",
7
7
  };
8
8
 
9
- # Hello World
9
+ # ようこそ
10
10
 
11
- ## Hello World
11
+ これは default テンプレートのスターターページです。`src/index.mdx` を編集して、実際のコンテンツに置き換えてください。
12
12
 
13
- ### Hello World
13
+ ## 含まれているもの
14
14
 
15
- #### Hello World
15
+ - Eleventy + Preact + Tailwind CSS
16
+ - MDX で書けるレイアウト・ページ
17
+ - `.client.jsx` 命名によるパーシャルハイドレーション
18
+ - Tailwind Typography による Markdown スタイル
16
19
 
17
- Hello World
20
+ ## Partial Hydration サンプル
21
+
22
+ 以下のカウンターは Preact コンポーネントで、初回操作時にクライアント側でハイドレーションされます。
18
23
 
19
24
  <Island component={Clicker} on="interaction" />
@@ -2,3 +2,14 @@
2
2
  @import "@jumpu-ui/tailwindcss";
3
3
  @plugin "@tailwindcss/typography";
4
4
  @plugin "@iconify/tailwind4";
5
+
6
+ @layer base {
7
+ html {
8
+ scroll-padding-top: 4rem;
9
+ }
10
+
11
+ :focus-visible {
12
+ outline: 2px solid AccentColor;
13
+ outline-offset: 2px;
14
+ }
15
+ }