2
0
Fork
You've already forked cms
0

UI indicators for SEO #49

Open
opened 2025年03月31日 09:42:35 +02:00 by RickCogley · 2 comments
RickCogley commented 2025年03月31日 09:42:35 +02:00 (Migrated from github.com)
Copy link

Thinking of SEO best practices and how the cms might help with this, it would be good if we could set, for a given field, some variables to have the UI indicate if the text entered in a field is acceptable length. Perhaps this is just a "soft" indication and does not prevent saving, just shows a message in the UI.

For example, if a title should be 70-90 char, maybe:

  • under 70 - "Title text is too short, consider adding"
  • over 90 - "Title text is too long, consider reducing"

Maybe it could also show a count of what you entered, as well...

Thinking of SEO best practices and how the cms might help with this, it would be good if we could set, for a given field, some variables to have the UI indicate if the text entered in a field is acceptable length. Perhaps this is just a "soft" indication and does not prevent saving, just shows a message in the UI. For example, if a title should be 70-90 char, maybe: * under 70 - "Title text is too short, consider adding" * over 90 - "Title text is too long, consider reducing" Maybe it could also show a count of what you entered, as well...
kylesloper commented 2025年07月10日 19:45:48 +02:00 (Migrated from github.com)
Copy link

This should be really easy to implement with a custom field.
https://lume.land/cms/fields/custom_fields/

This should be really easy to implement with a custom field. https://lume.land/cms/fields/custom_fields/

As a temporary workaround, you can use the init option of the fields, that allows to change any field configuration dynamically. For example:

{
 name: "title",
 type: "text",
 init(field, cms, data) {
 // Get the current title
 const value = data?.title;
 // Check the value length. Note that it can be empty (for example, in the creation form).
 if (value) {
 if (value.length > 90) {
 field.description = "<strong>Title text is too long,</strong> consider reducing";
 } else if (value.length < 70) {
 field.description = "<strong>Title text is too short,</strong> consider adding";
 }
 }
 }
}

This changes the description option of the field based on the current value. It's not perfect because it's not updated dynamically (the form is sent by AJAx, so you have to reload the page after saving the changes to see the new description). I have to think of a way to refresh the form.

To test this, use the version 0.12.1 or greater (there was a bug in 0.12.1 caused data not to be passed to the init function).

As a temporary workaround, you can use the `init` option of the fields, that allows to change any field configuration dynamically. For example: ```js { name: "title", type: "text", init(field, cms, data) { // Get the current title const value = data?.title; // Check the value length. Note that it can be empty (for example, in the creation form). if (value) { if (value.length > 90) { field.description = "<strong>Title text is too long,</strong> consider reducing"; } else if (value.length < 70) { field.description = "<strong>Title text is too short,</strong> consider adding"; } } } } ``` This changes the description option of the field based on the current value. It's not perfect because it's not updated dynamically (the form is sent by AJAx, so you have to reload the page after saving the changes to see the new description). I have to think of a way to refresh the form. To test this, use the version 0.12.1 or greater (there was a bug in 0.12.1 caused data not to be passed to the init function).
Sign in to join this conversation.
No Branch/Tag specified
main
lumecms/outra-versión
lumecms/proba-2
v0.15.7
v0.15.6
v0.15.5
v0.15.4
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.16
v0.14.15
v0.14.14
v0.14.13
v0.14.12
v0.14.11
v0.14.10
v0.14.9
v0.14.8
v0.14.7
v0.14.6
v0.14.5
v0.14.4
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.0
v0.13.0-beta.1
v0.13.0-beta.0
v0.12.5
v0.12.4
v0.12.3
v0.12.2
v0.12.1
v0.12.0
v0.11.5
v0.11.4
v0.11.3
v0.11.2
v0.11.1
v0.11.0
v0.10.5
v0.10.4
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.4
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.7
v0.7.6
v0.7.5
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.8
v0.6.7
v0.6.6
v0.6.5
v0.6.4
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.10
v0.5.9
v0.5.8
v0.5.7
v0.5.6
v0.5.5
v0.5.4
v0.5.3
v0.5.2
v0.5.1
v0.5.0
v0.4.3
v0.4.2
v0.4.1
v0.4.0
v0.3.12
v0.3.11
v0.3.10
v0.3.9
v0.3.8
v0.3.7
v0.3.6
v0.3.5
v0.3.4
v0.3.3
v0.3.2
v0.3.1
v0.3.0
v0.2.11
v0.2.10
v0.2.9
v0.2.8
v0.2.7
v0.2.6
v0.2.5
v0.2.4
v0.2.3
v0.2.2
v0.2.1
v0.2.0
v0.1.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lume/cms#49
Reference in a new issue
lume/cms
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?