mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Added basic Facebook settings in AdminX Settings
refs. https://github.com/TryGhost/Team/issues/3150
This commit is contained in:
parent
16fa1f5a53
commit
652be3f5fb
3 changed files with 73 additions and 3 deletions
|
@ -0,0 +1,68 @@
|
||||||
|
import React from 'react';
|
||||||
|
import SettingGroup from '../../../admin-x-ds/settings/SettingGroup';
|
||||||
|
import SettingGroupContent from '../../../admin-x-ds/settings/SettingGroupContent';
|
||||||
|
import TextField from '../../../admin-x-ds/global/TextField';
|
||||||
|
import useSettingGroup from '../../../hooks/useSettingGroup';
|
||||||
|
|
||||||
|
const Facebook: React.FC = () => {
|
||||||
|
const {
|
||||||
|
currentState,
|
||||||
|
focusRef,
|
||||||
|
handleSave,
|
||||||
|
handleCancel,
|
||||||
|
updateSetting,
|
||||||
|
getSettingValues,
|
||||||
|
handleStateChange
|
||||||
|
} = useSettingGroup();
|
||||||
|
|
||||||
|
const [facebookTitle, facebookDescription, siteTitle, siteDescription] = getSettingValues(['og_title', 'og_description', 'title', 'description']) as string[];
|
||||||
|
|
||||||
|
const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
updateSetting('og_title', e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDescriptionChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
updateSetting('og_description', e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const values = (
|
||||||
|
<div>
|
||||||
|
[TBD: facebook card preview]
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const inputFields = (
|
||||||
|
<SettingGroupContent>
|
||||||
|
<TextField
|
||||||
|
inputRef={focusRef}
|
||||||
|
placeholder={siteTitle}
|
||||||
|
title="Facebook title"
|
||||||
|
value={facebookTitle}
|
||||||
|
onChange={handleTitleChange}
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
placeholder={siteDescription}
|
||||||
|
title="Facebook description"
|
||||||
|
value={facebookDescription}
|
||||||
|
onChange={handleDescriptionChange}
|
||||||
|
/>
|
||||||
|
</SettingGroupContent>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SettingGroup
|
||||||
|
description='Customize structured data of your site'
|
||||||
|
navid='facebook'
|
||||||
|
state={currentState}
|
||||||
|
title='Facebook card'
|
||||||
|
onCancel={handleCancel}
|
||||||
|
onSave={handleSave}
|
||||||
|
onStateChange={handleStateChange}
|
||||||
|
>
|
||||||
|
{values}
|
||||||
|
{currentState !== 'view' ? inputFields : ''}
|
||||||
|
</SettingGroup>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Facebook;
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import Facebook from './Facebook';
|
||||||
import LockSite from './LockSite';
|
import LockSite from './LockSite';
|
||||||
import Metadata from './Metadata';
|
import Metadata from './Metadata';
|
||||||
import PublicationLanguage from './PublicationLanguage';
|
import PublicationLanguage from './PublicationLanguage';
|
||||||
|
@ -17,6 +18,7 @@ const GeneralSettings: React.FC = () => {
|
||||||
<TimeZone />
|
<TimeZone />
|
||||||
<PublicationLanguage />
|
<PublicationLanguage />
|
||||||
<Metadata />
|
<Metadata />
|
||||||
|
<Facebook />
|
||||||
<SocialAccounts />
|
<SocialAccounts />
|
||||||
<LockSite />
|
<LockSite />
|
||||||
<Users />
|
<Users />
|
||||||
|
|
|
@ -15,7 +15,7 @@ const Metadata: React.FC = () => {
|
||||||
handleStateChange
|
handleStateChange
|
||||||
} = useSettingGroup();
|
} = useSettingGroup();
|
||||||
|
|
||||||
const [metaTitle, metaDescription] = getSettingValues(['meta_title', 'meta_description']) as string[];
|
const [metaTitle, metaDescription, siteTitle, siteDescription] = getSettingValues(['meta_title', 'meta_description', 'title', 'description']) as string[];
|
||||||
|
|
||||||
const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
updateSetting('meta_title', e.target.value);
|
updateSetting('meta_title', e.target.value);
|
||||||
|
@ -36,14 +36,14 @@ const Metadata: React.FC = () => {
|
||||||
<TextField
|
<TextField
|
||||||
hint="Recommended: 70 characters"
|
hint="Recommended: 70 characters"
|
||||||
inputRef={focusRef}
|
inputRef={focusRef}
|
||||||
placeholder="[TBD: site title]"
|
placeholder={siteTitle}
|
||||||
title="Meta title"
|
title="Meta title"
|
||||||
value={metaTitle}
|
value={metaTitle}
|
||||||
onChange={handleTitleChange}
|
onChange={handleTitleChange}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
hint="Recommended: 156 characters"
|
hint="Recommended: 156 characters"
|
||||||
placeholder="[TBD: site description]"
|
placeholder={siteDescription}
|
||||||
title="Meta description"
|
title="Meta description"
|
||||||
value={metaDescription}
|
value={metaDescription}
|
||||||
onChange={handleDescriptionChange}
|
onChange={handleDescriptionChange}
|
||||||
|
|
Loading…
Add table
Reference in a new issue