Skip to content

Commit

Permalink
Merge pull request #145 from OpenSynergic/119-custom-metadata-element…
Browse files Browse the repository at this point in the history
…-untuk-masing-conference

add meta tag configuration
  • Loading branch information
rahmanramsi authored Nov 15, 2023
2 parents 4ecf136 + cd4522f commit bbeddcc
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/Http/Middleware/SetupDefaultData.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function setupSite()
View::share('contextName', $site->getMeta('name'));
View::share('footer', $site->getMeta('page_footer'));

MetaTag::add('description', $site->getMeta('description') ?? 'dsadsa');
MetaTag::add('description', $site->getMeta('description'));
}

protected function setupConference(Request $request, $currentConference)
Expand All @@ -57,6 +57,11 @@ protected function setupConference(Request $request, $currentConference)
View::share('footer', $currentConference->getMeta('page_footer'));
View::share('favicon', $currentConference->getFirstMediaUrl('favicon'));
View::share('styleSheet', $currentConference->getFirstMediaUrl('styleSheet'));

MetaTag::add('description', preg_replace("/\r|\n/", '', $currentConference->getMeta('description')));

foreach ($currentConference->getMeta('meta_tags') ?? [] as $name => $content) {
MetaTag::add($name, $content);
}
}
}
68 changes: 68 additions & 0 deletions app/Panel/Livewire/Forms/Conferences/SearchEngineSetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Panel\Livewire\Forms\Conferences;

use App\Actions\Conferences\ConferenceUpdateAction;
use App\Models\Conference;
use Filament\Forms\Components\Actions;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\KeyValue;
use Filament\Forms\Components\Section;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Livewire\Component;

class SearchEngineSetting extends Component implements HasForms
{
use InteractsWithForms;

public Conference $conference;

public ?array $formData = [];

public function mount(Conference $conference): void
{
$this->form->fill([
...$conference->attributesToArray(),
'meta' => $conference->getAllMeta(),
]);
}

public function render()
{
return view('panel.livewire.form');
}

public function form(Form $form): Form
{
return $form
->model($this->conference)
->schema([
Section::make()
->schema([
KeyValue::make('meta.meta_tags')
->keyLabel('Name')
->valueLabel('Content')

->helperText('Add meta tags, to the head of every page on your conference. Before adding any tags, consult with a technical advisor to ensure that they are compatible with your website and will not cause any problems.'),
]),
Actions::make([
Action::make('save')
->label('Save')
->successNotificationTitle('Saved!')
->failureNotificationTitle('Data could not be saved.')
->action(function (Action $action) {
$formData = $this->form->getState();
try {
ConferenceUpdateAction::run($this->conference, $formData);
$action->sendSuccessNotification();
} catch (\Throwable $th) {
$action->sendFailureNotification();
}
}),
])->alignLeft(),
])
->statePath('formData');
}
}
15 changes: 15 additions & 0 deletions app/Panel/Pages/Settings/ConferenceSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Panel\Livewire\Forms\Conferences\ContactSetting;
use App\Panel\Livewire\Forms\Conferences\InformationSetting;
use App\Panel\Livewire\Forms\Conferences\PrivacySetting;
use App\Panel\Livewire\Forms\Conferences\SearchEngineSetting;
use App\Panel\Livewire\Forms\Conferences\SetupSetting;
use App\Panel\Livewire\Forms\Conferences\SidebarSetting;
use Filament\Forms\Concerns\InteractsWithForms;
Expand Down Expand Up @@ -92,6 +93,20 @@ public function infolist(Infolist $infolist): Infolist
]),
]),
]),
Tabs\Tab::make('Distribution')
->schema([
InfolistsVerticalTabs\Tabs::make()
->schema([
InfolistsVerticalTabs\Tab::make('Search Indexing')
->icon('heroicon-o-magnifying-glass')
->schema([
LivewireEntry::make('sidebar-setting')
->livewire(SearchEngineSetting::class, [
'conference' => App::getCurrentConference(),
]),
]),
]),
]),
])
->contained(false),
]);
Expand Down

0 comments on commit bbeddcc

Please sign in to comment.