From 9957be9da8b10e5cdae3c5edd06ff4b952ad6a9e Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Fri, 23 Jan 2026 06:53:34 +0100 Subject: [PATCH] feat: support snake case alias for type definitions --- data/structures/_arguments.yml | 5 +++++ layouts/_partials/utilities/InitTypes.html | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data/structures/_arguments.yml b/data/structures/_arguments.yml index c95a5d2..124e628 100644 --- a/data/structures/_arguments.yml +++ b/data/structures/_arguments.yml @@ -4,6 +4,11 @@ arguments: optional: true comment: Unique name of the bookshop component. group: partial + _bookshop-name: + type: string + optional: true + comment: Alias for _bookshop_name. + group: partial _ordinal: type: int optional: true diff --git a/layouts/_partials/utilities/InitTypes.html b/layouts/_partials/utilities/InitTypes.html index cf09dca..ccb96c4 100644 --- a/layouts/_partials/utilities/InitTypes.html +++ b/layouts/_partials/utilities/InitTypes.html @@ -6,7 +6,13 @@ {{/* Inline partial to retrieve the type definition of the provided key (without recursion) */}} {{ define "_partials/inline/type-definition.html" }} - {{ $key := .key }} + {{/* Convert key name from snake case to kebab case, except for leading underscores. */}} + {{/* Examples: */}} + {{/* - "link_type" → "link-type" */}} + {{/* - "_link_type" → "_link-type" */}} + {{/* - "__link_type" → "__link-type" */}} + {{ $match := findRESubmatch "^(_*)(.*)$" .key }} + {{ $key := print (index $match 0 1) (replaceRE "_" "-" (index $match 0 2)) }} {{ $val := .val }} {{ $arguments := .arguments }} {{ $types := .types }}