fix: Set blog route if title and category are set
Set blog route on client side as soon as title and category are selected. This behavious is in line with Web Page, where the route is set as soon as the title is entered. This will ensure blog routes are consistent and contain category as the part of the route. The user can change the route ofcourse, but this behaviour is the most common expectation.
This commit is contained in:
parent
1d39b699cc
commit
4b2c82b9c9
1 changed files with 13 additions and 0 deletions
|
|
@ -11,16 +11,29 @@ frappe.ui.form.on('Blog Post', {
|
|||
},
|
||||
title: function(frm) {
|
||||
generate_google_search_preview(frm);
|
||||
frm.trigger('set_route');
|
||||
},
|
||||
meta_description: function(frm) {
|
||||
generate_google_search_preview(frm);
|
||||
},
|
||||
blog_intro: function(frm) {
|
||||
generate_google_search_preview(frm);
|
||||
},
|
||||
blog_category(frm) {
|
||||
frm.trigger('set_route');
|
||||
},
|
||||
set_route(frm) {
|
||||
if (frm.doc.route) return;
|
||||
if (frm.doc.title && frm.doc.blog_category) {
|
||||
frm.call('make_route').then(r => {
|
||||
frm.set_value('route', r.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function generate_google_search_preview(frm) {
|
||||
if (!frm.doc.title) return;
|
||||
let google_preview = frm.get_field("google_preview");
|
||||
let seo_title = (frm.doc.title).slice(0, 60);
|
||||
let seo_description = (frm.doc.meta_description || frm.doc.blog_intro || "").slice(0, 160);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue