@d-zero/scaffold 5.0.0-beta.4 → 5.0.0-beta.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-beta.5](https://github.com/d-zero-dev/frontend-env/compare/v5.0.0-beta.4...v5.0.0-beta.5) (2025-09-17)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **scaffold:** add dotenv ([f9e09fb](https://github.com/d-zero-dev/frontend-env/commit/f9e09fbc1e32f99dd0529b5fba40cc8c205471cb))
11
+ - **scaffold:** remove unnecessary async keyword from breadcrumbs function ([2e1e11f](https://github.com/d-zero-dev/frontend-env/commit/2e1e11f29face454705de7b359ab1bc598c549cf))
12
+ - **scaffold:** use rel="icon" for favicon ([af6c9e8](https://github.com/d-zero-dev/frontend-env/commit/af6c9e83c2bd2b454bf54745de0b8275063450d5))
13
+
14
+ ### Features
15
+
16
+ - **scaffold:** add dynamic breadcrumb generation ([4816002](https://github.com/d-zero-dev/frontend-env/commit/4816002823cb0698cac60858db26bffe081ab8e0))
17
+ - **scaffold:** add dynamic title generation using breadcrumbs ([39fd107](https://github.com/d-zero-dev/frontend-env/commit/39fd1076cd7d722bb97942751bc6f65826f93c1a))
18
+ - **scaffold:** update c-title-page component ([77d8bbe](https://github.com/d-zero-dev/frontend-env/commit/77d8bbe534392b1ae2bd82ea0e0da02287f32ff0))
19
+ - **scaffold:** update layout and template files ([6f95978](https://github.com/d-zero-dev/frontend-env/commit/6f9597865bf66e9d8f336a4e5e9db0462953116b))
20
+ - **scaffold:** update meta mixin, sample page and package config ([f97f141](https://github.com/d-zero-dev/frontend-env/commit/f97f1416ddd2053cdfab38823fe66adfdf3ef5f9))
21
+ - **scaffold:** update template data with Japanese titles ([7c60679](https://github.com/d-zero-dev/frontend-env/commit/7c606797db4a94b527de69b3ec79980fed275f61))
22
+
6
23
  # [5.0.0-beta.4](https://github.com/d-zero-dev/frontend-env/compare/v5.0.0-beta.3...v5.0.0-beta.4) (2025-08-14)
7
24
 
8
25
  ### Bug Fixes
@@ -1,42 +1,20 @@
1
1
  .c-nav-breadcrumb
2
2
  ol(itemscope itemtype="https://schema.org/BreadcrumbList")
3
- li.c-nav-breadcrumb__item(
4
- itemscope
5
- itemprop="itemListElement"
6
- itemtype="https://schema.org/ListItem"
7
- data-breadcrumb="home")
8
- a(
9
- href="/"
3
+ - const HOME_TITLE = "Home";
4
+ - const linkList = breadcrumbs(page, collections);
5
+ each link, index in linkList
6
+ li.c-nav-breadcrumb__item(
10
7
  itemscope
11
- itemprop="item"
12
- itemtype="https://schema.org/WebPage"
13
- itemid="/")
14
- span(itemprop="name") Home
15
- meta(itemprop="position" content="1")
16
- span.c-nav-breadcrumb__separetor
17
- li.c-nav-breadcrumb__item(
18
- itemscope
19
- itemprop="itemListElement"
20
- itemtype="https://schema.org/ListItem")
21
- a(
22
- href="/first/"
23
- itemscope
24
- itemprop="item"
25
- itemtype="https://schema.org/WebPage"
26
- itemid="/first/")
27
- span(itemprop="name") Parent
28
- meta(itemprop="position" content="2")
29
- span.c-nav-breadcrumb__separetor
30
- li.c-nav-breadcrumb__item(
31
- itemscope
32
- itemprop="itemListElement"
33
- itemtype="https://schema.org/ListItem"
34
- data-breadcrumb="current")
35
- a(
36
- href="/first/about"
37
- itemscope
38
- itemprop="item"
39
- itemtype="https://schema.org/WebPage"
40
- itemid="/first/about")
41
- span(itemprop="name") Current
42
- meta(itemprop="position" content="3")
8
+ itemprop="itemListElement"
9
+ itemtype="https://schema.org/ListItem"
10
+ data-breadcrumb=link.href === "/" ? "home" : undefined)
11
+ a(
12
+ href=link.href
13
+ itemscope
14
+ itemprop="item"
15
+ itemtype="https://schema.org/WebPage"
16
+ itemid=link.href)
17
+ span(itemprop="name")= link.href === "/" ? HOME_TITLE || link.title : link.title
18
+ meta(itemprop="position" content=index + 1)
19
+ if index < linkList.length - 1
20
+ span.c-nav-breadcrumb__separetor
@@ -1,2 +1,2 @@
1
1
  .c-title-page
2
- h1 ページタイトル
2
+ h1= title
@@ -0,0 +1,77 @@
1
+ import path from 'node:path';
2
+
3
+ import { JSDOM } from 'jsdom';
4
+
5
+ /**
6
+ *
7
+ */
8
+ export default function () {
9
+ return (page, collections) => {
10
+ const breadcrumbs = collections.all
11
+ .filter((item) => isAncestor(page, item.filePathStem))
12
+ .map((item) => ({
13
+ title: getTitle(item),
14
+ href: item.page.url,
15
+ depth: item.page.url.split('/').length,
16
+ }))
17
+ .sort((a, b) => a.depth - b.depth);
18
+ return breadcrumbs;
19
+ };
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @param page
25
+ * @param filePathStem
26
+ */
27
+ function isAncestor(page, filePathStem) {
28
+ const dirname = path.dirname(filePathStem);
29
+ const name = path.basename(filePathStem);
30
+ const included = page.filePathStem.startsWith(dirname);
31
+ const isIndex = name === 'index';
32
+ const isSelf = page.filePathStem === filePathStem;
33
+ return (included && isIndex) || isSelf;
34
+ }
35
+
36
+ const titleCache = new Map();
37
+
38
+ /**
39
+ *
40
+ * @param item
41
+ */
42
+ function getTitle(item) {
43
+ const filePathStem = item.filePathStem;
44
+ if (titleCache.has(filePathStem)) {
45
+ return titleCache.get(filePathStem);
46
+ }
47
+ const title =
48
+ item.data.title?.trim() ||
49
+ getTitleFromDOM(getContent(item)) ||
50
+ item.page.fileSlug?.trim();
51
+ titleCache.set(filePathStem, title);
52
+ return title;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @param item
58
+ */
59
+ function getTitleFromDOM(item) {
60
+ const content = getContent(item);
61
+ const dom = new JSDOM(content);
62
+ const title = dom.window.document.title.trim();
63
+ return title;
64
+ }
65
+
66
+ /**
67
+ *
68
+ * @param item
69
+ */
70
+ function getContent(item) {
71
+ try {
72
+ // UsingCircularTemplateContentReferenceError may potentially occur
73
+ return item.templateContent;
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
@@ -0,0 +1,16 @@
1
+ import breadcrumbs from './breadcrumbs.js';
2
+
3
+ /**
4
+ *
5
+ */
6
+ export default async function () {
7
+ return (page, collections, pkg, separator = ' | ') => {
8
+ const breadcrumbLinkList = breadcrumbs()(page, collections);
9
+ const titleList = breadcrumbLinkList
10
+ .filter((item) => item.href !== '/')
11
+ .toReversed()
12
+ .map((item) => item.title);
13
+ titleList.push(pkg.production?.siteName || '__サイト名__');
14
+ return titleList.join(separator);
15
+ };
16
+ }
@@ -2,7 +2,6 @@ doctype html
2
2
  html(lang=lang || "ja")
3
3
  head
4
4
  include /mixin/meta.pug
5
- +meta(title || "サイトタイトル")
6
5
  body.c-page-home
7
6
  .c-page-home__base
8
7
  .c-page-home__header
@@ -2,7 +2,6 @@ doctype html
2
2
  html(lang=lang || "ja")
3
3
  head
4
4
  include /mixin/meta.pug
5
- +meta(title || "サイトタイトル")
6
5
  body.c-page-sub
7
6
  .c-page-sub__base
8
7
  .c-page-sub__header
@@ -1,21 +1,25 @@
1
- mixin meta(title)
2
- meta(charset="UTF-8")
3
- meta(name="viewport" content="width=device-width")
4
- title= title
5
- meta(name="format-detection" content="telephone=no")
6
- meta(name="description" content="__ディスクリプション__")
7
- meta(property="og:type" content="website")
8
- meta(property="og:title" content="__サイトタイトル__")
9
- meta(property="og:site_name" content="__サイトタイトル__")
10
- meta(property="og:description" content="__ディスクリプション__")
11
- meta(property="og:url" content="__SNSからリンクさせるURL__")
12
- meta(property="og:image" content="__OGP用画像__")
13
- meta(name="twitter:card" content="summary_large_image")
14
- meta(name="twitter:url" content="__SNSからリンクさせるURL__")
15
- meta(name="twitter:title" content="__サイトタイトル__")
16
- meta(name="twitter:description" content="__ディスクリプション__")
17
- meta(name="twitter:image" content="__OGP用画像__")
18
- link(rel="shortcut icon" href="/favicon.png")
19
- link(rel="apple-touch-icon" href="/img/apple-touch-icon.png")
20
- link(href="/css/style.css" rel="stylesheet")
21
- script(src="/js/script.js" type="module")
1
+ meta(charset="UTF-8")
2
+ meta(name="viewport" content="width=device-width")
3
+ title= titlelist(page, collections, pkg, " | ")
4
+ meta(name="format-detection" content="telephone=no")
5
+ meta(name="description" content=description || "")
6
+ meta(property="og:type" content=ogType || "website")
7
+ if pkg.production.siteName
8
+ meta(property="og:site_name" content=pkg.production.siteName || "__サイト名__")
9
+ if ogDescription || description
10
+ meta(property="og:description" content=ogDescription || description || "")
11
+ if pkg.production.host
12
+ meta(property="og:url" content=pkg.production.host + page.url)
13
+ meta(property="og:image" content=pkg.production.host + (ogImage || "/img/ogp.png"))
14
+ meta(name="twitter:card" content=ogCard || "summary_large_image")
15
+ meta(name="twitter:url" content=pkg.production.host + page.url)
16
+ if pkg.production.siteName
17
+ meta(name="twitter:title" content=pkg.production.siteName || "__サイト名__")
18
+ if ogDescription || description
19
+ meta(name="twitter:description" content=ogDescription || description || "")
20
+ if pkg.production.host
21
+ meta(name="twitter:image" content=pkg.production.host + (ogImage || "/img/ogp.png"))
22
+ link(rel="icon" href="/favicon.png")
23
+ link(rel="apple-touch-icon" href="/img/apple-touch-icon.png")
24
+ link(href="/css/style.css" rel="stylesheet")
25
+ script(src="/js/script.js" type="module")
@@ -1,3 +1,4 @@
1
1
  {
2
- "layout": "home.pug"
2
+ "layout": "home.pug",
3
+ "title": "トップページ"
3
4
  }
@@ -1,3 +1,4 @@
1
1
  {
2
- "layout": "sub.pug"
2
+ "layout": "sub.pug",
3
+ "title": "下層固定ページ・ブログ詳細ページ"
3
4
  }
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "layout": "sub.pug",
3
+ "title": "ブログA一覧ページ",
3
4
  "hasPagination": true
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "layout": "sub.pug",
3
+ "title": "ブログB一覧ページ",
3
4
  "hasPagination": true
4
5
  }
@@ -1,3 +1,4 @@
1
1
  {
2
- "layout": "sub.pug"
2
+ "layout": "sub.pug",
3
+ "title": "メールフォーム入力ページ"
3
4
  }
@@ -1,3 +1,4 @@
1
1
  {
2
- "layout": "sub.pug"
2
+ "layout": "sub.pug",
3
+ "title": "メールフォーム確認ページ"
3
4
  }
@@ -1,3 +1,4 @@
1
1
  {
2
- "layout": "sub.pug"
2
+ "layout": "sub.pug",
3
+ "title": "メールフォーム完了ページ"
3
4
  }
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  layout: sub.pug
3
3
  title: サンプルページ
4
+ description: サンプルページの説明
4
5
  ---
5
6
 
6
7
  <div class="c-content-main">
@@ -1,8 +1,6 @@
1
- include /mixin/meta.pug
2
-
3
1
  html(lang="ja")
4
2
  head
5
- +meta("__テスト用ファイル__")
3
+ include /mixin/meta.pug
6
4
  body
7
5
  main
8
6
  h1 Hello World!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/scaffold",
3
- "version": "5.0.0-beta.4",
3
+ "version": "5.0.0-beta.5",
4
4
  "description": "Frontend scaffold files of D-ZERO Co., Ltd.",
5
5
  "repository": "https://github.com/d-zero-dev/frontend-env.git",
6
6
  "author": "D-ZERO Co., Ltd.",
@@ -10,6 +10,10 @@
10
10
  },
11
11
  "type": "module",
12
12
  "main": "package.json",
13
+ "production": {
14
+ "host": "https://example.com",
15
+ "siteName": "__サイト名__"
16
+ },
13
17
  "scripts": {
14
18
  "build": "yarn lint && npx @d-zero/builder",
15
19
  "build:only": "npx @d-zero/builder",
@@ -39,30 +43,32 @@
39
43
  "last 2 ios_saf version"
40
44
  ],
41
45
  "devDependencies": {
42
- "@burger-editor/local": "4.0.0-alpha.14",
43
- "@d-zero/builder": "5.0.0-beta.4",
44
- "@d-zero/linters": "5.0.0-alpha.70",
45
- "@d-zero/postcss-config": "5.0.0-beta.4",
46
+ "@burger-editor/local": "4.0.0-alpha.20",
47
+ "@d-zero/builder": "5.0.0-beta.5",
48
+ "@d-zero/linters": "5.0.0-alpha.71",
49
+ "@d-zero/postcss-config": "5.0.0-beta.5",
46
50
  "@d-zero/tsconfig": "0.5.0",
47
- "@types/node": "22.17.1",
51
+ "@types/node": "24.5.1",
48
52
  "cross-env": "10.0.0",
53
+ "dotenv": "17.2.2",
49
54
  "husky": "9.1.7",
55
+ "jsdom": "27.0.0",
50
56
  "npm-run-all2": "8.0.4",
51
57
  "typescript": "5.9.2",
52
58
  "vitest": "3.2.4"
53
59
  },
54
60
  "dependencies": {
55
- "@burger-editor/css": "4.0.0-alpha.14",
56
- "@d-zero/custom-components": "5.0.0-beta.4",
61
+ "@burger-editor/css": "4.0.0-alpha.20",
62
+ "@d-zero/custom-components": "5.0.0-beta.5",
57
63
  "dialog-toggle-events-polyfill": "1.1.4",
58
- "invokers-polyfill": "0.5.6",
64
+ "invokers-polyfill": "0.5.7",
59
65
  "kiso.css": "1.2.2",
60
66
  "tslib": "2.8.1"
61
67
  },
62
- "packageManager": "yarn@4.9.2",
68
+ "packageManager": "yarn@4.9.4",
63
69
  "volta": {
64
- "node": "24.5.0",
65
- "yarn": "4.9.2"
70
+ "node": "24.8.0",
71
+ "yarn": "4.9.4"
66
72
  },
67
- "gitHead": "ba3d7a51a1b1d9da5653ff24039c91be3c9a8b0e"
73
+ "gitHead": "d1c2f9a70e6d4c4d72e823489b1cc79468b20965"
68
74
  }