Set limit for posts subtitle #987

Closed
opened 2022-01-04 10:49:55 +00:00 by mskf1383 · 5 comments
Contributor

some users write all of the post's content in subtitle part and it's awfull!
Please set a limit for subtitle.
I think 154 is standard for SEO. Because it use as description in meta tags.
Thanks!

some users write all of the post's content in subtitle part and it's awfull! Please set a limit for subtitle. I think 154 is standard for SEO. Because it use as description in meta tags. Thanks!

You're right. We will implement.

Thank you!

You're right. We will implement. Thank you!
KitaitiMakoto added this to the 0.8.0 milestone 2022-01-04 10:52:55 +00:00

This might occur because it's hard to distinguish subtitle area and content area in rich text editor. If so, we should fix rich text editor.

This might occur because it's hard to distinguish subtitle area and content area in rich text editor. If so, we should fix rich text editor.

A first way would be to add .truncate(154) on this function

fn get_subtitle() -> String {

So that it becomes:

fn get_subtitle() -> String {
    let subtitle = 
    	if is_basic_editor() {
        	get_elt_value("subtitle")
    	} else {
        	document()
            	.query_selector("#plume-editor > h2")
            	.unwrap()
            	.unwrap()
            	.dyn_ref::<HtmlElement>()
            	.unwrap()
            	.inner_text()
    	};
   subtitle.truncate(154);
   return subtitle;
}

Using https://doc.rust-lang.org/std/string/struct.String.html#method.truncate .

But then, this magic value of 154 has to be defined in some other file, in order to be easily modifiable.
I'm not familiar with Rust way of having a huge file with many useful constants, but maybe the lib.rs file could be a good one, where we put some:

const MAX_SUBTITLE_SIZE = 154;

Then we just have to import it and use it in place of 154.

A first way would be to add `.truncate(154)` on this function https://git.joinplu.me/Plume/Plume/src/commit/31b144c76de97fea4d07647285a87431d1d655cc/plume-front/src/editor.rs#L127 So that it becomes: ```rust fn get_subtitle() -> String { let subtitle = if is_basic_editor() { get_elt_value("subtitle") } else { document() .query_selector("#plume-editor > h2") .unwrap() .unwrap() .dyn_ref::<HtmlElement>() .unwrap() .inner_text() }; subtitle.truncate(154); return subtitle; } ``` Using https://doc.rust-lang.org/std/string/struct.String.html#method.truncate . But then, this *magic value* of 154 has to be defined in some other file, in order to be easily modifiable. I'm not familiar with Rust way of having a huge file with many useful constants, but maybe the **lib.rs** file could be a good one, where we put some: ```rust const MAX_SUBTITLE_SIZE = 154; ``` Then we just have to import it and use it in place of 154.

Near 500 characters might be good because Mastodon shows subtitle and it shows at most 500 characters.

Near 500 characters might be good because Mastodon shows subtitle and it shows at most 500 characters.

I found the same issue: #627

I found the same issue: #627
Sign in to join this conversation.
No milestone
No project
No assignees
3 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: Plume/Plume#987
No description provided.