Better SEO form previews (#61)

This commit is contained in:
Chirag 2023-01-05 19:46:06 +05:30 committed by GitHub
parent 9783b07778
commit 5486768125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -160,9 +160,16 @@ class SeoMetaResolver
{
$form = Form::whereSlug($this->patternData['slug'])->firstOrFail();
return [
$meta = [
'title' => $form->title . $this->titleSuffix(),
];
if($form->description){
$meta['description'] = Str::of($form->description)->limit(160);
}
if($form->cover_picture){
$meta['image'] = $form->cover_picture;
}
return $meta;
}
private function getTemplateShowMeta(): array

View File

@ -46,6 +46,7 @@ import { mapState } from 'vuex'
import OpenCompleteForm from '../../components/open/forms/OpenCompleteForm'
import Cookies from 'js-cookie'
import sha256 from 'js-sha256'
import SeoMeta from '../../mixins/seo-meta'
const isFrame = window.location !== window.parent.location || window.frameElement
@ -106,6 +107,7 @@ function loadForm (slug) {
export default {
components: { OpenCompleteForm },
mixins: [SeoMeta],
beforeRouteEnter (to, from, next) {
if (window.$crisp) {
@ -172,6 +174,12 @@ export default {
metaTitle () {
return this.form ? this.form.title : 'Create beautiful forms'
},
metaDescription () {
return (this.form && this.form.description) ? this.form.description.substring(0,160) : null
},
metaImage () {
return (this.form && this.form.cover_picture) ? this.form.cover_picture : null
},
metaTags () {
return (this.form && this.form.can_be_indexed) ? [] : [{ name: 'robots', content: 'noindex' }]
}