page update
This commit is contained in:
1 parent
ee5cba3634
commit
9a105ba45e
8 files changed
+66
-34
No files matched your search
+7
-2
@@ -6,7 +6,7 @@ import { Meta } from 'src/components/Meta'
|
|||||||
import { MetaBuilder } from 'src/lib/meta'
|
import { MetaBuilder } from 'src/lib/meta'
|
||||||
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
import { NextPage } from 'next'
|
import { NextPage } from 'next'
|
||||||
import { IBreadcumbsPart, IMeta, IPage } from 'src/types'
|
import { IBreadcumbsPart, IMeta, IPage, ITag } from 'src/types'
|
||||||
|
|
||||||
function array<T>(value: T | T[]) {
|
function array<T>(value: T | T[]) {
|
||||||
return Array.isArray(value)
|
return Array.isArray(value)
|
||||||
@@ -16,6 +16,8 @@ function array<T>(value: T | T[]) {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
title: string
|
||||||
|
tags: ITag[]
|
||||||
|
date: string
|
||||||
content: string
|
content: string
|
||||||
breadcrumb: IBreadcumbsPart[]
|
breadcrumb: IBreadcumbsPart[]
|
||||||
meta?: IMeta
|
meta?: IMeta
|
||||||
@@ -37,7 +39,8 @@ const Index: NextPage<Props> = props => (
|
|||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<Page
|
<Page
|
||||||
showSocialShare={true}
|
tags={props.tags}
|
||||||
|
date={props.date ? new Date(props.date) : null}
|
||||||
>
|
>
|
||||||
{props.content}
|
{props.content}
|
||||||
</Page>
|
</Page>
|
||||||
@@ -68,6 +71,8 @@ export const unstable_getStaticProps = async (ctx: any) => {
|
|||||||
props: {
|
props: {
|
||||||
content: page.data,
|
content: page.data,
|
||||||
title: page.title,
|
title: page.title,
|
||||||
|
tags: page.tags,
|
||||||
|
date: page.date,
|
||||||
meta,
|
meta,
|
||||||
breadcrumb,
|
breadcrumb,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,38 @@
|
|||||||
import { Share } from '../Share'
|
import { Share } from '../Share'
|
||||||
import { Html } from '../Html'
|
import { Html } from '../Html'
|
||||||
|
import { PageMeta } from '../PageMeta'
|
||||||
|
import { ITag } from 'src/types'
|
||||||
|
|
||||||
export interface IPageProps {
|
export interface IPageProps {
|
||||||
showSocialShare: boolean
|
|
||||||
children: string
|
children: string
|
||||||
|
date: Date
|
||||||
|
tags: ITag[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Page: React.FC<IPageProps> = props => (
|
export const Page: React.FC<IPageProps> = props => (
|
||||||
<div className={'Article'}>
|
<div className={'Article'}>
|
||||||
|
<style jsx>{`
|
||||||
|
hr {
|
||||||
|
border: 1px solid black;
|
||||||
|
margin-top: var(--size-m);
|
||||||
|
margin-bottom: var(--size-m);
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
<div className={'Article-Body'}>
|
<div className={'Article-Body'}>
|
||||||
<Html
|
<Html
|
||||||
html={props.children}
|
html={props.children}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!props.showSocialShare ? null : (
|
<hr />
|
||||||
<Share />
|
<Share />
|
||||||
)}
|
|
||||||
|
<PageMeta
|
||||||
|
style={{
|
||||||
|
marginTop: 'var(--size-m)',
|
||||||
|
}}
|
||||||
|
date={props.date}
|
||||||
|
tags={props.tags}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import * as React from 'react'
|
|
||||||
import { dateFormat } from '../../lib/date'
|
|
||||||
|
|
||||||
export interface IPageHeaderProps {
|
|
||||||
tags?: string[]
|
|
||||||
date?: Date
|
|
||||||
title: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PageHeader: React.FC<IPageHeaderProps> = props => (
|
|
||||||
<header className="Article-Head">
|
|
||||||
<h1>{props.title}</h1>
|
|
||||||
|
|
||||||
{!props.date ? null : (
|
|
||||||
<p className="date">{dateFormat(props.date)}</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* {!(tags.length) ? null : (
|
|
||||||
<TagList tags={tags} />
|
|
||||||
)} */}
|
|
||||||
</header>
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import './styles.css'
|
||||||
|
|
||||||
|
import { dateFormat } from 'src/lib/date'
|
||||||
|
import { ITag } from 'src/types'
|
||||||
|
import { TagList } from '../TagList'
|
||||||
|
|
||||||
|
export type PageMetaProps = {
|
||||||
|
style?: React.CSSProperties
|
||||||
|
date?: Date
|
||||||
|
tags?: ITag[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PageMeta: React.FC<PageMetaProps> = props => (
|
||||||
|
<header className={'pageMeta'} style={props.style}>
|
||||||
|
{!props.date ? null : (
|
||||||
|
<p className={'date'}>Опубликовано: {dateFormat(props.date)}</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!(props.tags.length) ? null : (
|
||||||
|
<TagList items={props.tags} />
|
||||||
|
)}
|
||||||
|
</header>
|
||||||
|
)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
.pageMeta {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
@@ -5,7 +5,13 @@ import { Button } from '../Button'
|
|||||||
|
|
||||||
export const Tag: React.FC<{ href: string }> = props => (
|
export const Tag: React.FC<{ href: string }> = props => (
|
||||||
<li className={'tagsItem'}>
|
<li className={'tagsItem'}>
|
||||||
<Button href={props.href}>{props.children}</Button>
|
<Button
|
||||||
|
href={props.href}
|
||||||
|
size={'small'}
|
||||||
|
disabled={true}
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
</Button>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +26,7 @@ export const TagList: React.FC<TagListProps> = props => (
|
|||||||
key={x.slug}
|
key={x.slug}
|
||||||
href={x.href}
|
href={x.href}
|
||||||
>
|
>
|
||||||
# {x.name}
|
{x.name}
|
||||||
</Tag>
|
</Tag>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -6,10 +6,6 @@
|
|||||||
hyphens: auto;
|
hyphens: auto;
|
||||||
margin-bottom: var(--post-margin);
|
margin-bottom: var(--post-margin);
|
||||||
|
|
||||||
&-Head {
|
|
||||||
margin-bottom: 1.25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin-bottom: var(--size-s);
|
margin-bottom: var(--size-s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ export interface IPage {
|
|||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
data: string
|
data: string
|
||||||
|
date: string
|
||||||
preview: ImageDefinition
|
preview: ImageDefinition
|
||||||
description: string
|
description: string
|
||||||
tokens: any[]
|
tokens: any[]
|
||||||
|
tags: ITag[]
|
||||||
breadcrumb?: IBreadcumbsPart[]
|
breadcrumb?: IBreadcumbsPart[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user