Skip to content

Commit

Permalink
Restructure metadata fields
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Oct 25, 2023
1 parent 6727b44 commit 4dd98e3
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions src/input/metadata/MetadataField.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {Field, Meta, Type, type} from 'alinea/core'
import {Field, Type, type} from 'alinea/core'
import {link} from 'alinea/input/link'
import {tab, tabs} from 'alinea/input/tabs'
import {ObjectField, object} from 'alinea/input/object'
import {TextField, text} from 'alinea/input/text'
import {IcBaselineWifiTethering} from 'alinea/ui/icons/IcBaselineWifiTethering'
import IcRoundSearch from 'alinea/ui/icons/IcRoundSearch'
import {ImageReference} from '../../picker/entry/EntryReference.js'
import {LinkField} from '../link/LinkField.js'

Expand All @@ -16,11 +14,11 @@ export interface MetadataOptions {
export interface MetadataFields {
title: TextField
description: TextField
image: LinkField<ImageReference>
'search:title': TextField
'search:description': TextField
'og:title': TextField
'og:description': TextField
openGraph: ObjectField<{
title: TextField
image: LinkField<ImageReference>
description: TextField
}>
}

export class MetadataField extends Field.Record<
Expand All @@ -31,25 +29,14 @@ export class MetadataField extends Field.Record<
export function metadata(options: MetadataOptions = {}) {
const fields = type('Fields', {
title: text('Title', {width: 0.5}),
image: link.image('Image', {width: 0.5}),
description: text('Description', {multiline: true}),
...tabs(
tab('Search engines', {
'search:title': text('Title', {width: 0.5}),
'search:description': text('Description', {multiline: true}),
[Meta]: {
icon: IcRoundSearch
}
}),

tab('Social media', {
'og:title': text('Title', {width: 0.5}),
'og:description': text('Description', {multiline: true}),
[Meta]: {
icon: IcBaselineWifiTethering
}
openGraph: object('Open graph', {
fields: type('Open graph fields', {
title: text('Title', {width: 0.5}),
image: link.image('Image', {width: 0.5}),
description: text('Description', {multiline: true})
})
)
})
})
return new MetadataField(Type.shape(fields), {
hint: Type.hint(fields),
Expand Down

0 comments on commit 4dd98e3

Please sign in to comment.