2024-07-03 21:25:03 +00:00
|
|
|
import { Meta } from '@solidjs/meta'
|
|
|
|
import { useNavigate } from '@solidjs/router'
|
2023-11-14 15:10:00 +00:00
|
|
|
import { clsx } from 'clsx'
|
2024-07-03 21:25:03 +00:00
|
|
|
import { createMemo } from 'solid-js'
|
|
|
|
import { AuthGuard } from '~/components/AuthGuard'
|
|
|
|
import { Button } from '~/components/_shared/Button'
|
|
|
|
import { Icon } from '~/components/_shared/Icon'
|
|
|
|
import { PageLayout } from '~/components/_shared/PageLayout'
|
2024-07-04 07:51:15 +00:00
|
|
|
import enKeywords from '~/config/locales/en/keywords.json'
|
|
|
|
import ruKeywords from '~/config/locales/ru/keywords.json'
|
2024-07-03 21:25:03 +00:00
|
|
|
import { useGraphQL } from '~/context/graphql'
|
|
|
|
import { useLocalize } from '~/context/localize'
|
|
|
|
import createShoutMutation from '~/graphql/mutation/core/article-create'
|
2024-07-03 21:39:29 +00:00
|
|
|
import styles from '~/styles/Create.module.scss'
|
2024-07-03 21:25:03 +00:00
|
|
|
import { LayoutType } from '~/types/common'
|
|
|
|
import { getImageUrl } from '~/utils/getImageUrl'
|
2023-02-17 09:21:02 +00:00
|
|
|
|
2024-07-03 21:25:03 +00:00
|
|
|
export default () => {
|
|
|
|
const { t, lang } = useLocalize()
|
2023-12-13 10:39:31 +00:00
|
|
|
const ogImage = getImageUrl('production/image/logo_image.png')
|
2024-07-03 21:25:03 +00:00
|
|
|
const ogTitle = createMemo(() => t('Choose a post type'))
|
|
|
|
const description = createMemo(() =>
|
|
|
|
t('Participate in the Discours: share information, join the editorial team')
|
|
|
|
)
|
|
|
|
const client = useGraphQL()
|
|
|
|
const navigate = useNavigate()
|
|
|
|
const handleCreate = async (layout: LayoutType) => {
|
|
|
|
const result = await client.mutation(createShoutMutation, { article: { layout: layout } }).toPromise()
|
|
|
|
if (result) {
|
|
|
|
const shout = result.data.create_shout
|
|
|
|
if (shout?.id) navigate(`/edit/${shout.id}`)
|
|
|
|
}
|
|
|
|
}
|
2023-02-17 09:21:02 +00:00
|
|
|
return (
|
2024-07-05 08:11:57 +00:00
|
|
|
<PageLayout title={`${t('Discours')} :: ${ogTitle()}`}>
|
2024-07-03 21:25:03 +00:00
|
|
|
<Meta name="descprition" content={description()} />
|
|
|
|
<Meta name="keywords" content={lang() === 'ru' ? ruKeywords[''] : enKeywords['']} />
|
2023-12-13 10:39:31 +00:00
|
|
|
<Meta name="og:type" content="article" />
|
2024-07-03 21:25:03 +00:00
|
|
|
<Meta name="og:title" content={ogTitle()} />
|
2023-12-13 10:39:31 +00:00
|
|
|
<Meta name="og:image" content={ogImage} />
|
|
|
|
<Meta name="twitter:image" content={ogImage} />
|
2024-07-03 21:25:03 +00:00
|
|
|
<Meta name="og:description" content={description()} />
|
2023-12-13 10:39:31 +00:00
|
|
|
<Meta name="twitter:card" content="summary_large_image" />
|
2024-07-03 21:25:03 +00:00
|
|
|
<Meta name="twitter:title" content={ogTitle()} />
|
|
|
|
<Meta name="twitter:description" content={description()} />
|
2023-09-21 11:38:22 +00:00
|
|
|
<AuthGuard>
|
|
|
|
<article class={clsx('wide-container', 'container--static-page', styles.Create)}>
|
|
|
|
<h1>{t('Choose a post type')}</h1>
|
|
|
|
<ul class={clsx('nodash', styles.list)}>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('article')}>
|
|
|
|
<Icon name="create-article" class={styles.icon} />
|
|
|
|
<div>{t('article')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('literature')}>
|
|
|
|
<Icon name="create-books" class={styles.icon} />
|
|
|
|
<div>{t('literature')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('image')}>
|
|
|
|
<Icon name="create-images" class={styles.icon} />
|
|
|
|
<div>{t('images')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
2023-11-28 13:18:25 +00:00
|
|
|
<div class={styles.link} onClick={() => handleCreate('audio')}>
|
2023-09-21 11:38:22 +00:00
|
|
|
<Icon name="create-music" class={styles.icon} />
|
|
|
|
<div>{t('music')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<div class={styles.link} onClick={() => handleCreate('video')}>
|
|
|
|
<Icon name="create-video" class={styles.icon} />
|
|
|
|
<div>{t('video')}</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<Button value={t('Back')} onClick={() => window.history.back()} />
|
|
|
|
</article>
|
|
|
|
</AuthGuard>
|
2023-02-17 09:21:02 +00:00
|
|
|
</PageLayout>
|
|
|
|
)
|
|
|
|
}
|