maglevhq / maglev-core

Ruby on Rails website builder
https://www.maglev.dev
MIT License
273 stars 47 forks source link

Incorrect `link` values #44

Closed hasaniskandar closed 1 year ago

hasaniskandar commented 1 year ago

Section generator produces url to specify the URL for sample and default value of link settings, but the editor didn't pick it up until we rename it to href.

Steps to reproduce

Create a new section with link settings, e.g.:

bundle exec rails generate maglev:section section_01 \
  --category=content \
  --settings call_to_action:link block:list_item:item_link:link

Expected behavior

Generates sample and default values in correct format: { text: "Link", href: "#" }.

Actual behavior

Generates sample and default values in incorrect format: { text: "Link", url: "#" }.

--- a/app/theme/sections/content/section_01.yml [EXPECTATION]
+++ b/app/theme/sections/content/section_01.yml [ACTUAL]
@@ -1,59 +1,59 @@
 # Name of the section displayed in the editor UI
 name: "Section 01"

 # Category of the section in the editor UI (headers, features, testimonials, ...etc)
 category: content

 # A section might have the same content all over the site, like a menu or a footer for instance.
 # To enable this behavior, uncomment the following statement
 # site_scoped: true

 # Display or not the button to insert a new section after this one
 # insert_button: false

 # Insert this section at the top or the bottom of the page (default: nil)
 # insert_at: top 

 # One single instance per page?
 # singleton: true

 # Definition of the settings:
 # A setting type can be one of the following values: text, image, link, collection_item, checkbox, color and icon.
 # Please visit: https://docs.maglev.dev/concepts/setting for more explanation.
 settings:
 - label: "Call to action"
   id: call_to_action
   type: link
   with_text: true
-  default: { text: "Link", href: "#" }
+  default: { text: "Link", url: "#" }
 # Definition of the blocks.
 # You can define as many types of blocks as you want.
 blocks: 
 - name: "List item"
   type: list_item
   settings:
   - label: "Item link"
     id: item_link
     type: link
     with_text: true
-    default: { text: "Link", href: "#" }
+    default: { text: "Link", url: "#" }

 # By default, in the editor UI, blocks will be listed below the "Content" title.
 # The title can be changed with the following property:
 # blocks_label: "My list of items"

 # By default, blocks are presented as a list in the editor UI. 
 # If you like to use blocks to build a menu with sub menu items, 
 # consider using the tree presentation
 # blocks_presentation: "tree"

 # In order to get a section with "meaning" content for the editors, 
 # you can set the default content of a new instance of this section.
 # (it's also be useful when taking a screenshot of the section).
 # sample:
 #   settings:
-#     call_to_action: { text: "Link", href: "#" }
+#     call_to_action: { text: "Link", url: "#" }
 #   blocks: 
 #   - type: list_item
 #     settings:
-#       item_link: { text: "Link", href: "#" }        
+#       item_link: { text: "Link", url: "#" }        

System configuration

Maglev version: 1.1.7 Rails version: 7.0.4.2 Ruby version: 3.2.0