store
2 months ago
GenerateBgImage.js
2 months ago
block-duplicate-helper.js
2 months ago
capitalize.js
2 months ago
color-code-to-class.js
2 months ago
color-slug-to-color-code.js
2 months ago
common.scss
2 weeks ago
convert-to-grid.js
2 months ago
default-color-palette.js
2 months ago
delete-from-array.js
2 months ago
depModules.js
2 months ago
disable-links.js
2 weeks ago
empty-string-to-undefined.js
2 months ago
example-data.js
2 months ago
fixBrokenUnicode.js
2 months ago
font-awesome-new.js
2 weeks ago
font-awesome-version.js
2 months ago
font-awesome.js
2 months ago
formatNumCol.js
2 months ago
gradient-slug-to-gradient-code.js
2 months ago
heading-level-utils.js
2 months ago
hex-to-rgba.js
2 months ago
horizontal-scroll-controls.js
2 months ago
icon-label.js
2 weeks ago
is-excludes-blocks.js
2 months ago
is-gradient-style.js
2 months ago
is-hex-color.js
2 months ago
is-not-json.js
2 months ago
is-parent-reusable-block.js
1 day ago
merge-colors.js
2 months ago
multi-array-flaten.js
2 months ago
removeProperty.js
2 months ago
replaceClientId.js
2 months ago
sanitizeSlug.js
2 months ago
settings-page-url.js
2 weeks ago
strip-html.js
2 months ago
taxonomy-utils.js
2 months ago
to-number.js
2 months ago
to-preset-spacing-var.js
2 months ago
unit-options.js
2 months ago
wrap-unwrap.js
2 months ago
heading-level-utils.js
41 lines
| 1 | /** |
| 2 | * 見出しレベル設定に関する� |
| 3 | �通ユーティリティ関数 |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * 最大レベルに基づいて見出しレベル� |
| 8 | �列を生成する |
| 9 | * |
| 10 | * @param {string} maxLevel - 最大レベル('h2', 'h3', 'h4', 'h5', 'h6') |
| 11 | * @return {Array} 見出しレベル� |
| 12 | �列(例:['h2', 'h3', 'h4']) |
| 13 | */ |
| 14 | export const generateHeadingLevels = (maxLevel) => { |
| 15 | const levels = ['h2']; |
| 16 | const levelNumbers = ['h2', 'h3', 'h4', 'h5', 'h6']; |
| 17 | const maxIndex = levelNumbers.indexOf(maxLevel); |
| 18 | |
| 19 | if (maxIndex !== -1) { |
| 20 | levels.push(...levelNumbers.slice(1, maxIndex + 1)); |
| 21 | } |
| 22 | |
| 23 | return levels; |
| 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * 現在の見出しレベル� |
| 28 | �列から最大レベルを取得する |
| 29 | * |
| 30 | * @param {Array} currentLevels - 現在の見出しレベル� |
| 31 | �列 |
| 32 | * @return {string} 最大レベル(デフォルト:'h6') |
| 33 | */ |
| 34 | export const getCurrentMaxLevel = (currentLevels) => { |
| 35 | if (!currentLevels || currentLevels.length === 0) { |
| 36 | return 'h6'; |
| 37 | } |
| 38 | const maxLevel = currentLevels[currentLevels.length - 1]; |
| 39 | return maxLevel || 'h6'; |
| 40 | }; |
| 41 |