70 files changed
+4233
-2485
No files matched your search
@@ -1,26 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es6": true
|
|
||||||
},
|
|
||||||
"extends": "standard",
|
|
||||||
"plugins": [
|
|
||||||
"standard",
|
|
||||||
"promise",
|
|
||||||
"react",
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"semi": ["error", "never"],
|
|
||||||
"space-before-function-paren": "off",
|
|
||||||
"comma-dangle": "off",
|
|
||||||
"no-tabs": "off",
|
|
||||||
"indent": ["error", "tab"],
|
|
||||||
"react/jsx-uses-react": "error",
|
|
||||||
"react/jsx-uses-vars": "error",
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaFeatures": {
|
|
||||||
"jsx": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"extends": "next/core-web-vitals",
|
||||||
|
"rules": {
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"space-before-function-paren": "off",
|
||||||
|
"comma-dangle": [
|
||||||
|
"error",
|
||||||
|
"always-multiline"
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"warn",
|
||||||
|
"double"
|
||||||
|
],
|
||||||
|
"no-tabs": "off",
|
||||||
|
"indent": [
|
||||||
|
"warn",
|
||||||
|
4
|
||||||
|
],
|
||||||
|
"eol-last": ["error", "always"],
|
||||||
|
"react/jsx-uses-react": "error",
|
||||||
|
"react/jsx-uses-vars": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
Vendored
-1
@@ -1,5 +1,4 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/types/global" />
|
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
|
|||||||
Generated
+3590
-1871
File diff suppressed because it is too large.
Load diff
+8
-6
@@ -7,6 +7,7 @@
|
|||||||
"start": "next start",
|
"start": "next start",
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
"lint": "next lint",
|
||||||
"sitemap": "node scripts/sitemap.js",
|
"sitemap": "node scripts/sitemap.js",
|
||||||
"feed": "node scripts/feed.js"
|
"feed": "node scripts/feed.js"
|
||||||
},
|
},
|
||||||
@@ -17,18 +18,17 @@
|
|||||||
"author": "Roman Timashev",
|
"author": "Roman Timashev",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.21.2",
|
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"date-fns": "^2.11.1",
|
"date-fns": "^2.11.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"markdown-it": "^12.3.2",
|
"markdown-it": "^13.0.1",
|
||||||
"next": "^12.1.6",
|
"next": "^12.2.5",
|
||||||
"rc-tooltip": "^5.1.0",
|
"rc-tooltip": "^5.1.0",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-icons": "^4.2.0",
|
"react-icons": "^4.2.0",
|
||||||
"react-use": "^17.2.1",
|
"react-use": "^17.2.1",
|
||||||
"sharp": "^0.30.6",
|
"sharp": "^0.31.0",
|
||||||
"sitemap": "^1.5.0",
|
"sitemap": "^1.5.0",
|
||||||
"typograf": "^6.11.1",
|
"typograf": "^6.11.1",
|
||||||
"use-media": "^1.4.0"
|
"use-media": "^1.4.0"
|
||||||
@@ -36,12 +36,14 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/classnames": "^2.2.10",
|
"@types/classnames": "^2.2.10",
|
||||||
"@types/lodash": "^4.14.149",
|
"@types/lodash": "^4.14.149",
|
||||||
|
"@types/markdown-it": "^12.2.3",
|
||||||
"@types/node": "^12.12.34",
|
"@types/node": "^12.12.34",
|
||||||
"@types/react": "^16.9.32",
|
"@types/react": "^16.9.32",
|
||||||
"@types/sharp": "^0.29.2",
|
"@types/sharp": "^0.29.2",
|
||||||
"eslint": "^7.1.0",
|
"eslint": "^8.23.0",
|
||||||
|
"eslint-config-next": "12.2.5",
|
||||||
"feed": "^4.1.0",
|
"feed": "^4.1.0",
|
||||||
"should": "^8.2.2",
|
"should": "^8.2.2",
|
||||||
"typescript": "^4.4.2"
|
"typescript": "^4.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+83
-84
@@ -1,20 +1,20 @@
|
|||||||
import Head from 'next/head'
|
import Head from "next/head"
|
||||||
import { App } from 'src/components/App'
|
import { App } from "src/components/App"
|
||||||
import { tail } from 'lodash'
|
import { tail } from "lodash"
|
||||||
import { Page } from 'src/components/Page'
|
import { Page } from "src/components/Page"
|
||||||
import { Meta } from 'src/components/Meta'
|
import { Meta } from "src/components/Meta"
|
||||||
import { MetaBuilder } from 'src/lib/meta'
|
import { MetaBuilder } from "src/lib/meta"
|
||||||
import { apiGet } from '@/next-lib'
|
import { apiGet } from "@/next-lib"
|
||||||
import { GetStaticProps, NextPage } from 'next'
|
import { GetStaticProps, NextPage } from "next"
|
||||||
import { IBreadcumbsPart, IMenu, IMeta, ITag, Sign, Token } from '@/types'
|
import { IBreadcumbsPart, IMenu, IMeta, ITag, Sign, Token } from "@/types"
|
||||||
import { Html } from 'src/components/Html'
|
import { Html } from "src/components/Html"
|
||||||
import { Youtube } from '@/components/Youtube'
|
import { Youtube } from "@/components/Youtube"
|
||||||
import { createMenu, createPage, createPageUrls } from '@/remote/factory'
|
import { createMenu, createPage, createPageUrls } from "@/remote/factory"
|
||||||
import { paramsToSlug } from '@/remote/lib'
|
import { paramsToSlug } from "@/remote/lib"
|
||||||
import { PageGrid } from '@/components/PageGrid'
|
import { PageGrid } from "@/components/PageGrid"
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from "next/router"
|
||||||
import { FileCard } from '@/components/FIleCard'
|
import { FileCard } from "@/components/FIleCard"
|
||||||
import { Picture } from '@/components/Picture'
|
import { Picture } from "@/components/Picture"
|
||||||
|
|
||||||
async function getUrls() {
|
async function getUrls() {
|
||||||
let urls: string[] = []
|
let urls: string[] = []
|
||||||
@@ -59,8 +59,8 @@ const Index: NextPage<Props> = props => {
|
|||||||
return (
|
return (
|
||||||
<App
|
<App
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
marginTop: 'var(--size-l)',
|
marginTop: "var(--size-l)",
|
||||||
marginBottom: 'var(--size-xl)',
|
marginBottom: "var(--size-xl)",
|
||||||
}}
|
}}
|
||||||
menu={props.menu}
|
menu={props.menu}
|
||||||
breadcrumbs={props.breadcrumb}
|
breadcrumbs={props.breadcrumb}
|
||||||
@@ -76,70 +76,70 @@ const Index: NextPage<Props> = props => {
|
|||||||
tags={props.tags}
|
tags={props.tags}
|
||||||
date={props.date ? new Date(props.date) : undefined}
|
date={props.date ? new Date(props.date) : undefined}
|
||||||
>
|
>
|
||||||
<article className={'article'}>
|
<article className={"article"}>
|
||||||
{props.tokens.map((x, i) => {
|
{props.tokens.map((x, i) => {
|
||||||
switch (x.token) {
|
switch (x.token) {
|
||||||
case 'html':
|
case "html":
|
||||||
return (
|
return (
|
||||||
<Html
|
<Html
|
||||||
key={i}
|
key={i}
|
||||||
html={x.data}
|
html={x.data}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'instagram':
|
case "instagram":
|
||||||
return (
|
return (
|
||||||
<Html
|
<Html
|
||||||
key={i}
|
key={i}
|
||||||
html={x.data.embed}
|
html={x.data.embed}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'youtube':
|
case "youtube":
|
||||||
return (
|
return (
|
||||||
<Youtube
|
<Youtube
|
||||||
key={i}
|
key={i}
|
||||||
url={x.data.url}
|
url={x.data.url}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'image':
|
case "image":
|
||||||
return (
|
return (
|
||||||
<Picture
|
<Picture
|
||||||
key={i}
|
key={i}
|
||||||
src={x.data.src}
|
src={x.data.src}
|
||||||
alt={x.data.alt}
|
alt={x.data.alt}
|
||||||
width={x.data.width}
|
width={x.data.width}
|
||||||
height={x.data.height}
|
height={x.data.height}
|
||||||
caption={x.data.caption}
|
caption={x.data.caption}
|
||||||
blur={x.data.blur}
|
blur={x.data.blur}
|
||||||
wide={x.wide}
|
wide={x.wide}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'file':
|
case "file":
|
||||||
return (
|
return (
|
||||||
<FileCard
|
<FileCard
|
||||||
key={i}
|
key={i}
|
||||||
sign={props.documentSignature}
|
sign={props.documentSignature}
|
||||||
{...x.data}
|
{...x.data}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'grid':
|
case "grid":
|
||||||
return (
|
return (
|
||||||
<PageGrid
|
<PageGrid
|
||||||
key={i}
|
key={i}
|
||||||
items={x.data.items}
|
items={x.data.items}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<pre key={i}>
|
<pre key={i}>
|
||||||
{JSON.stringify(x)}
|
{JSON.stringify(x)}
|
||||||
</pre>
|
</pre>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
</article>
|
</article>
|
||||||
@@ -158,8 +158,7 @@ export const getStaticProps: GetStaticProps<Props> = async ctx => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu = await apiGet(createMenu)
|
const menu = await apiGet(createMenu)("https://hudozka.tmshv.com/menu", () => [])
|
||||||
('https://hudozka.tmshv.com/menu', () => [])
|
|
||||||
|
|
||||||
const description = page.description ?? undefined
|
const description = page.description ?? undefined
|
||||||
const breadcrumbSize = page?.breadcrumb?.length ?? 0
|
const breadcrumbSize = page?.breadcrumb?.length ?? 0
|
||||||
@@ -182,12 +181,12 @@ export const getStaticProps: GetStaticProps<Props> = async ctx => {
|
|||||||
menu,
|
menu,
|
||||||
breadcrumb,
|
breadcrumb,
|
||||||
documentSignature: {
|
documentSignature: {
|
||||||
date: '20.01.2021г.',
|
date: "20.01.2021г.",
|
||||||
person: 'Тимашева Марина Геннадьевна',
|
person: "Тимашева Марина Геннадьевна",
|
||||||
position: 'Директор',
|
position: "Директор",
|
||||||
signature: '0ac4ea89753a4ba9893799442325fb41',
|
signature: "0ac4ea89753a4ba9893799442325fb41",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +197,7 @@ export const getStaticPaths = async () => {
|
|||||||
fallback: true,
|
fallback: true,
|
||||||
paths: urls
|
paths: urls
|
||||||
.map(path => {
|
.map(path => {
|
||||||
const slug = tail(path.split('/'))
|
const slug = tail(path.split("/"))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
+10
-17
@@ -1,13 +1,13 @@
|
|||||||
import 'src/style/style.css'
|
import "src/style/style.css"
|
||||||
import 'src/style/content.css'
|
import "src/style/content.css"
|
||||||
import 'src/style/article.css'
|
import "src/style/article.css"
|
||||||
import 'src/style/marker/marker-table.css'
|
import "src/style/marker/marker-table.css"
|
||||||
import 'src/style/kazimir/video.css'
|
import "src/style/kazimir/video.css"
|
||||||
|
|
||||||
import App from 'next/app'
|
import App from "next/app"
|
||||||
import Head from 'next/head'
|
import Head from "next/head"
|
||||||
import { YMetrika } from 'src/components/YMetrika'
|
import { YMetrika } from "src/components/YMetrika"
|
||||||
import { GAnalytics } from 'src/components/GAnalytics'
|
import { GAnalytics } from "src/components/GAnalytics"
|
||||||
|
|
||||||
export default class MyApp extends App {
|
export default class MyApp extends App {
|
||||||
render() {
|
render() {
|
||||||
@@ -38,15 +38,8 @@ export default class MyApp extends App {
|
|||||||
href="/feed.xml"
|
href="/feed.xml"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Google Fonts */}
|
|
||||||
<link
|
|
||||||
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;900&display=swap"
|
|
||||||
rel="preload"
|
|
||||||
as="style"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<YMetrika account={24027460} />
|
<YMetrika account={24027460} />
|
||||||
<GAnalytics account={'UA-60209057-1'} />
|
<GAnalytics account={"UA-60209057-1"} />
|
||||||
</Head>
|
</Head>
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Html, Head, Main, NextScript } from "next/document"
|
||||||
|
|
||||||
|
export default function Document() {
|
||||||
|
return (
|
||||||
|
<Html>
|
||||||
|
<Head>
|
||||||
|
{/* Google Fonts */}
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;900&display=swap"
|
||||||
|
rel="preload"
|
||||||
|
as="style"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</Head>
|
||||||
|
<body>
|
||||||
|
<Main />
|
||||||
|
<NextScript />
|
||||||
|
</body>
|
||||||
|
</Html>
|
||||||
|
)
|
||||||
|
}
|
||||||
+8
-8
@@ -1,22 +1,22 @@
|
|||||||
import { NextPage } from 'next'
|
import { NextPage } from "next"
|
||||||
import { Wrapper } from 'src/components/Wrapper'
|
import { Wrapper } from "src/components/Wrapper"
|
||||||
import { NotFound } from 'src/components/NotFound'
|
import { NotFound } from "src/components/NotFound"
|
||||||
import { Copyright } from 'src/components/Copyright'
|
import { Copyright } from "src/components/Copyright"
|
||||||
import { Block } from 'src/components/Block'
|
import { Block } from "src/components/Block"
|
||||||
import { Spacer } from 'src/components/Spacer'
|
import { Spacer } from "src/components/Spacer"
|
||||||
|
|
||||||
const Index: NextPage = () => (
|
const Index: NextPage = () => (
|
||||||
<Wrapper
|
<Wrapper
|
||||||
header={null}
|
header={null}
|
||||||
footer={(
|
footer={(
|
||||||
<Block as={'footer'} direction={'horizontal'}>
|
<Block as={"footer"} direction={"horizontal"}>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Copyright />
|
<Copyright />
|
||||||
<Spacer />
|
<Spacer />
|
||||||
</Block>
|
</Block>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Block direction={'vertical'}>
|
<Block direction={"vertical"}>
|
||||||
<NotFound />
|
<NotFound />
|
||||||
<Spacer />
|
<Spacer />
|
||||||
</Block>
|
</Block>
|
||||||
|
|||||||
+16
-18
@@ -1,13 +1,13 @@
|
|||||||
import Head from 'next/head'
|
import Head from "next/head"
|
||||||
import { App } from 'src/components/App'
|
import { App } from "src/components/App"
|
||||||
import { Meta } from 'src/components/Meta'
|
import { Meta } from "src/components/Meta"
|
||||||
import { PageGrid } from 'src/components/PageGrid'
|
import { PageGrid } from "src/components/PageGrid"
|
||||||
import { HudozkaTitle } from 'src/components/HudozkaTitle'
|
import { HudozkaTitle } from "src/components/HudozkaTitle"
|
||||||
import { MetaBuilder } from 'src/lib/meta'
|
import { MetaBuilder } from "src/lib/meta"
|
||||||
import { GetStaticProps, NextPage } from 'next'
|
import { GetStaticProps, NextPage } from "next"
|
||||||
import { IMenu, IMeta, PageCardDto } from 'src/types'
|
import { IMenu, IMeta, PageCardDto } from "src/types"
|
||||||
import { apiGet } from '@/next-lib'
|
import { apiGet } from "@/next-lib"
|
||||||
import { createHomeCards, createMenu } from '@/remote/factory'
|
import { createHomeCards, createMenu } from "@/remote/factory"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
title: string
|
||||||
@@ -28,8 +28,8 @@ const Index: NextPage<Props> = props => (
|
|||||||
|
|
||||||
<HudozkaTitle
|
<HudozkaTitle
|
||||||
style={{
|
style={{
|
||||||
marginTop: 'var(--size-m)',
|
marginTop: "var(--size-m)",
|
||||||
marginBottom: 'var(--size-m)',
|
marginBottom: "var(--size-m)",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -40,16 +40,14 @@ const Index: NextPage<Props> = props => (
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const getStaticProps: GetStaticProps<Props> = async () => {
|
export const getStaticProps: GetStaticProps<Props> = async () => {
|
||||||
const items = await apiGet(createHomeCards)
|
const items = await apiGet(createHomeCards)("https://hudozka.tmshv.com/home", async () => [])
|
||||||
('https://hudozka.tmshv.com/home', async () => [])
|
const menu = await apiGet(createMenu)("https://hudozka.tmshv.com/menu", () => [])
|
||||||
const menu = await apiGet(createMenu)
|
|
||||||
('https://hudozka.tmshv.com/menu', () => [])
|
|
||||||
|
|
||||||
const title = 'Шлиссельбургская ДХШ'
|
const title = "Шлиссельбургская ДХШ"
|
||||||
const meta = (new MetaBuilder())
|
const meta = (new MetaBuilder())
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setData({
|
.setData({
|
||||||
url: '/',
|
url: "/",
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import dynamic from 'next/dynamic'
|
import dynamic from "next/dynamic"
|
||||||
import { Wrapper } from '../Wrapper'
|
import { Wrapper } from "../Wrapper"
|
||||||
import { ConfigContext } from 'src/context/ConfigContext'
|
import { ConfigContext } from "src/context/ConfigContext"
|
||||||
import config from 'src/config'
|
import config from "src/config"
|
||||||
import { Footer } from '../Footer'
|
import { Footer } from "../Footer"
|
||||||
import { Content } from '../Content'
|
import { Content } from "../Content"
|
||||||
import { Block } from '../Block'
|
import { Block } from "../Block"
|
||||||
import { Breadcrumbs } from '../Breadcrumbs'
|
import { Breadcrumbs } from "../Breadcrumbs"
|
||||||
import { IBreadcumbsPart, IMenu } from 'src/types'
|
import { IBreadcumbsPart, IMenu } from "src/types"
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from "next/router"
|
||||||
import { useMobile } from 'src/hooks/useMobile'
|
import { useMobile } from "src/hooks/useMobile"
|
||||||
import { Gosuslugi } from '../Gosuslugi'
|
import { Gosuslugi } from "../Gosuslugi"
|
||||||
import { INavigationProps } from '@/components/Navigation'
|
import { INavigationProps } from "@/components/Navigation"
|
||||||
|
|
||||||
const Navigation = dynamic<INavigationProps>(() => import('../Navigation').then(mod => mod.Navigation), {
|
const Navigation = dynamic<INavigationProps>(() => import("../Navigation").then(mod => mod.Navigation), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ export const App: React.FC<IAppProps> = ({ showAuthor = false, menu, ...props })
|
|||||||
const hideBreadcrumbs = useMobile()
|
const hideBreadcrumbs = useMobile()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const blockStyle = {
|
const blockStyle = {
|
||||||
justifyContent: 'center'
|
justifyContent: "center",
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -39,10 +39,10 @@ export const App: React.FC<IAppProps> = ({ showAuthor = false, menu, ...props })
|
|||||||
header={(
|
header={(
|
||||||
<header>
|
<header>
|
||||||
<Navigation style={{
|
<Navigation style={{
|
||||||
margin: '0 var(--size-m) var(--size-m)',
|
margin: "0 var(--size-m) var(--size-m)",
|
||||||
}} />
|
}} />
|
||||||
{hideBreadcrumbs || !props.breadcrumbs ? null : (
|
{hideBreadcrumbs || !props.breadcrumbs ? null : (
|
||||||
<Block direction={'horizontal'} style={blockStyle}>
|
<Block direction={"horizontal"} style={blockStyle}>
|
||||||
<Content>
|
<Content>
|
||||||
<Breadcrumbs
|
<Breadcrumbs
|
||||||
items={props.breadcrumbs}
|
items={props.breadcrumbs}
|
||||||
@@ -58,7 +58,7 @@ export const App: React.FC<IAppProps> = ({ showAuthor = false, menu, ...props })
|
|||||||
showAuthor={showAuthor}
|
showAuthor={showAuthor}
|
||||||
>
|
>
|
||||||
<div style={{
|
<div style={{
|
||||||
backgroundColor: 'white',
|
backgroundColor: "white",
|
||||||
padding: 10,
|
padding: 10,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
marginBottom: 30,
|
marginBottom: 30,
|
||||||
@@ -68,7 +68,7 @@ export const App: React.FC<IAppProps> = ({ showAuthor = false, menu, ...props })
|
|||||||
</Footer>
|
</Footer>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Block direction={'horizontal'} style={blockStyle}>
|
<Block direction={"horizontal"} style={blockStyle}>
|
||||||
<Content style={props.contentStyle}>
|
<Content style={props.contentStyle}>
|
||||||
{props.children}
|
{props.children}
|
||||||
</Content>
|
</Content>
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { createElement } from 'react'
|
import { createElement } from "react"
|
||||||
|
|
||||||
export type BlockProps = {
|
export type BlockProps = {
|
||||||
as?: keyof HTMLElementTagNameMap
|
as?: keyof HTMLElementTagNameMap
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
direction: 'horizontal' | 'vertical'
|
direction: "horizontal" | "vertical"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Block: React.FC<BlockProps> = ({ as = 'div', style, direction, ...props }) => {
|
export const Block: React.FC<BlockProps> = ({ as = "div", style, direction, ...props }) => {
|
||||||
const directionClass = direction === 'horizontal'
|
const directionClass = direction === "horizontal"
|
||||||
? s.horizontal
|
? s.horizontal
|
||||||
: s.vertical
|
: s.vertical
|
||||||
const newProps = {
|
const newProps = {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import { IBreadcumbsPart } from 'src/types'
|
import { IBreadcumbsPart } from "src/types"
|
||||||
import { Button } from '../Button'
|
import { Button } from "../Button"
|
||||||
import { insertBetween } from 'src/lib/array'
|
import { insertBetween } from "src/lib/array"
|
||||||
|
|
||||||
export type BreadcrumbsProps = {
|
export type BreadcrumbsProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -11,15 +11,15 @@ export type BreadcrumbsProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Breadcrumbs: React.FC<BreadcrumbsProps> = props => {
|
export const Breadcrumbs: React.FC<BreadcrumbsProps> = props => {
|
||||||
const items = insertBetween(props.items, () => '/')
|
const items = insertBetween(props.items, () => "/")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className={s.breadcrumbs} style={props.style}>
|
<nav className={s.breadcrumbs} style={props.style}>
|
||||||
{items.map((x, i) => {
|
{items.map((x, i) => {
|
||||||
if (typeof x === 'string') {
|
if (typeof x === "string") {
|
||||||
return (
|
return (
|
||||||
<li key={i}>
|
<li key={i}>
|
||||||
<span style={{ margin: '0 var(--size-xs)' }}>{x}</span>
|
<span style={{ margin: "0 var(--size-xs)" }}>{x}</span>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,8 @@ export const Breadcrumbs: React.FC<BreadcrumbsProps> = props => {
|
|||||||
<li key={x.href}>
|
<li key={x.href}>
|
||||||
<Button
|
<Button
|
||||||
href={x.href}
|
href={x.href}
|
||||||
theme={'ghost'}
|
theme={"ghost"}
|
||||||
size={'small'}
|
size={"small"}
|
||||||
disabled={x.href === props.path}
|
disabled={x.href === props.path}
|
||||||
>
|
>
|
||||||
{x.name}
|
{x.name}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import Link from 'next/link'
|
import Link from "next/link"
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { useCallback } from 'react'
|
import { useCallback } from "react"
|
||||||
|
|
||||||
const sizeClass = {
|
const sizeClass = {
|
||||||
default: s.sizeDefault,
|
default: s.sizeDefault,
|
||||||
@@ -10,7 +10,7 @@ const sizeClass = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const themeClass = {
|
const themeClass = {
|
||||||
default: '',
|
default: "",
|
||||||
icon: s.themeIcon,
|
icon: s.themeIcon,
|
||||||
ghost: s.themeGhost,
|
ghost: s.themeGhost,
|
||||||
}
|
}
|
||||||
@@ -19,13 +19,13 @@ export type ButtonProps = {
|
|||||||
value?: any
|
value?: any
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
href?: string
|
href?: string
|
||||||
theme?: 'default' | 'ghost' | 'icon'
|
theme?: "default" | "ghost" | "icon"
|
||||||
size?: 'default' | 'small'
|
size?: "default" | "small"
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
onClick?: (value: any, event: MouseEvent) => void
|
onClick?: (value: any, event: MouseEvent) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Button: React.FC<ButtonProps> = ({ size = 'default', theme = 'default', disabled = false, ...props }) => {
|
export const Button: React.FC<ButtonProps> = ({ size = "default", theme = "default", disabled = false, ...props }) => {
|
||||||
const className = cx(s.button, sizeClass[size], themeClass[theme], {
|
const className = cx(s.button, sizeClass[size], themeClass[theme], {
|
||||||
[s.disabled]: disabled,
|
[s.disabled]: disabled,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import Link from 'next/link'
|
import Link from "next/link"
|
||||||
|
|
||||||
const layoutClass = {
|
const layoutClass = {
|
||||||
simple: s.simple,
|
simple: s.simple,
|
||||||
featured: s.featured,
|
featured: s.featured,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CardLayout = 'simple' | 'featured'
|
export type CardLayout = "simple" | "featured"
|
||||||
export type CardProps = {
|
export type CardProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
href: string
|
href: string
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
export type CardGridProps = {
|
export type CardGridProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.strong {
|
||||||
|
margin-bottom: var(--size-m);
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
margin-bottom: var(--size-s);
|
||||||
|
}
|
||||||
@@ -1,25 +1,22 @@
|
|||||||
import { useContext } from 'react'
|
import s from "./contacts.module.css"
|
||||||
import { ConfigContext } from 'src/context/ConfigContext'
|
|
||||||
|
import { useContext } from "react"
|
||||||
|
import { ConfigContext } from "src/context/ConfigContext"
|
||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
export const Contacts: React.FC = props => {
|
export const Contacts: React.FC = props => {
|
||||||
const { contacts } = useContext(ConfigContext)
|
const { contacts } = useContext(ConfigContext)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<style jsx>{`
|
<strong className={s.strong}>Контактная информация</strong>
|
||||||
strong {
|
|
||||||
margin-bottom: var(--size-m);
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin-bottom: var(--size-s);
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
<strong>Контактная информация</strong>
|
|
||||||
|
|
||||||
{contacts.map((x, i) => (
|
{contacts.map((x, i) => (
|
||||||
<p key={i}><a href={x.value}>{x.title}</a></p>
|
<p key={i} className={s.link}>
|
||||||
|
<Link href={x.value}>
|
||||||
|
<a >{x.title}</a>
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { useReducedMotion } from 'src/hooks/useReducedMotion'
|
import { useReducedMotion } from "src/hooks/useReducedMotion"
|
||||||
|
|
||||||
export type ContentProps = {
|
export type ContentProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -10,8 +10,8 @@ export const Content: React.FC<ContentProps> = props => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cx('content', {
|
className={cx("content", {
|
||||||
'reduced-motion': motionDisabled,
|
"reduced-motion": motionDisabled,
|
||||||
})}
|
})}
|
||||||
style={props.style}
|
style={props.style}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useContext } from 'react'
|
import { useContext } from "react"
|
||||||
import { ConfigContext } from 'src/context/ConfigContext'
|
import { ConfigContext } from "src/context/ConfigContext"
|
||||||
|
|
||||||
export const Copyright: React.FC = () => {
|
export const Copyright: React.FC = () => {
|
||||||
const { yearStart, yearEnd } = useContext(ConfigContext)
|
const { yearStart, yearEnd } = useContext(ConfigContext)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import 'rc-tooltip/assets/bootstrap_white.css'
|
import "rc-tooltip/assets/bootstrap_white.css"
|
||||||
import s from './signature.module.css'
|
import s from "./signature.module.css"
|
||||||
|
|
||||||
import { Sign } from '@/types'
|
import { Sign } from "@/types"
|
||||||
import { FiShield } from 'react-icons/fi'
|
import { FiShield } from "react-icons/fi"
|
||||||
import Tooltip from 'rc-tooltip'
|
import Tooltip from "rc-tooltip"
|
||||||
|
|
||||||
export type SignatureProps = Sign
|
export type SignatureProps = Sign
|
||||||
export const Signature: React.FC<SignatureProps> = props => {
|
export const Signature: React.FC<SignatureProps> = props => {
|
||||||
@@ -17,7 +17,7 @@ export const Signature: React.FC<SignatureProps> = props => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip overlayClassName={'hudozka'} placement="left" trigger={['hover', 'click']} overlay={content}>
|
<Tooltip overlayClassName={"hudozka"} placement="left" trigger={["hover", "click"]} overlay={content}>
|
||||||
<FiShield className={s.secure} size={20} />
|
<FiShield className={s.secure} size={20} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import s from './filecard.module.css'
|
import s from "./filecard.module.css"
|
||||||
|
|
||||||
import Image from 'next/image'
|
import Image from "next/image"
|
||||||
import { FileTokenData, Sign } from '@/types'
|
import { FileTokenData, Sign } from "@/types"
|
||||||
import { size, ext } from '@/lib/file'
|
import { size, ext } from "@/lib/file"
|
||||||
import { getResizedUrl } from '@/lib/image'
|
import { getResizedUrl } from "@/lib/image"
|
||||||
import { Signature } from './Signature'
|
import { Signature } from "./Signature"
|
||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
export type FileCardProps = FileTokenData & {
|
export type FileCardProps = FileTokenData & {
|
||||||
sign?: Sign
|
sign?: Sign
|
||||||
@@ -28,9 +29,10 @@ export const FileCard: React.FC<FileCardProps> = props => {
|
|||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
src={props.image_url}
|
src={props.image_url}
|
||||||
|
alt={""}
|
||||||
width={100}
|
width={100}
|
||||||
height={100}
|
height={100}
|
||||||
objectFit={'contain'}
|
objectFit={"contain"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
@@ -45,9 +47,11 @@ export const FileCard: React.FC<FileCardProps> = props => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={s.info}>
|
<div className={s.info}>
|
||||||
<a href={props.file_url} target="_blank">
|
<Link href={props.file_url}>
|
||||||
{format} ({fileSize})
|
<a target="_blank" rel="noreferrer">
|
||||||
</a>
|
{format} ({fileSize})
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import { FileDefinition } from 'src/types'
|
import { FileDefinition } from "src/types"
|
||||||
import { ext, size } from 'src/lib/file'
|
import { ext, size } from "src/lib/file"
|
||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
export type FileProps = FileDefinition & {
|
export type FileProps = FileDefinition & {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -11,17 +12,21 @@ export const File: React.SFC<FileProps> = props => (
|
|||||||
<div className={s.file} style={props.style}>
|
<div className={s.file} style={props.style}>
|
||||||
{!props.cover?.src ? null : (
|
{!props.cover?.src ? null : (
|
||||||
<div className={s.image}>
|
<div className={s.image}>
|
||||||
<a href={props.file.src} target="_blank" className="invisible">
|
<Link href={props.file.src} >
|
||||||
<img src={props.cover.src} alt={props.name} />
|
<a target="_blank" rel="noreferrer" className="invisible">
|
||||||
</a>
|
<img src={props.cover.src} alt={props.name} />
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={s.info}>
|
<div className={s.info}>
|
||||||
<span>{props.name}</span>
|
<span>{props.name}</span>
|
||||||
<a href={props.file.src} target="_blank">
|
<Link href={props.file.src} >
|
||||||
{ext(props.file.type)} ({size(props.file.size)})
|
<a target="_blank" rel="noreferrer">
|
||||||
</a>
|
{ext(props.file.type)} ({size(props.file.size)})
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
export const Author: React.FC = () => (
|
export const Author: React.FC = () => (
|
||||||
<span>
|
<span>
|
||||||
Разработка и поддержка сайта —
|
Разработка и поддержка сайта —
|
||||||
<a href="http://tmshv.ru?utm_source=artshburg&utm_medium=developer&utm_campaign=tmshv_ru">
|
<a href="http://tmshv.ru?utm_source=artshburg&utm_medium=developer&utm_campaign=tmshv_ru">
|
||||||
www.tmshv.ru
|
www.tmshv.ru
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
@@ -1,32 +1,32 @@
|
|||||||
import s from './footer.module.css'
|
import s from "./footer.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { Copyright } from '../Copyright'
|
import { Copyright } from "../Copyright"
|
||||||
import { Author } from './Author'
|
import { Author } from "./Author"
|
||||||
import { Block } from '../Block'
|
import { Block } from "../Block"
|
||||||
import { Spacer } from '../Spacer'
|
import { Spacer } from "../Spacer"
|
||||||
import { Contacts } from '../Contacts'
|
import { Contacts } from "../Contacts"
|
||||||
|
|
||||||
export interface IFooterProps {
|
export interface IFooterProps {
|
||||||
showAuthor: boolean
|
showAuthor: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Footer: React.FC<IFooterProps> = props => (
|
export const Footer: React.FC<IFooterProps> = props => (
|
||||||
<footer className={cx(s.footer, 'opposite')}>
|
<footer className={cx(s.footer, "opposite")}>
|
||||||
<Block direction={'vertical'} style={{
|
<Block direction={"vertical"} style={{
|
||||||
marginBottom: 'var(--size-l)',
|
marginBottom: "var(--size-l)",
|
||||||
}}>
|
}}>
|
||||||
<Contacts />
|
<Contacts />
|
||||||
</Block>
|
</Block>
|
||||||
|
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|
||||||
<Block direction={'horizontal'}>
|
<Block direction={"horizontal"}>
|
||||||
<Copyright />
|
<Copyright />
|
||||||
|
|
||||||
{!props.showAuthor ? null : (
|
{!props.showAuthor ? null : (
|
||||||
<>
|
<>
|
||||||
<Spacer as={'span'} />
|
<Spacer as={"span"} />
|
||||||
<Author />
|
<Author />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React from "react"
|
||||||
|
|
||||||
function script(account) {
|
function script(account) {
|
||||||
return `
|
return `
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useEffect } from 'react'
|
import { useEffect } from "react"
|
||||||
import { getCode } from './lib'
|
import { getCode } from "./lib"
|
||||||
|
|
||||||
export type GosuslugiProps = {}
|
export type GosuslugiProps = {}
|
||||||
|
|
||||||
export const Gosuslugi: React.FC<GosuslugiProps> = () => {
|
export const Gosuslugi: React.FC<GosuslugiProps> = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.dispatchEvent(new Event('resize'))
|
window.dispatchEvent(new Event("resize"))
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createElement } from 'react'
|
import { createElement } from "react"
|
||||||
|
|
||||||
export type HtmlProps = {
|
export type HtmlProps = {
|
||||||
className?: string
|
className?: string
|
||||||
@@ -6,11 +6,11 @@ export type HtmlProps = {
|
|||||||
html: string
|
html: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Html: React.FC<HtmlProps> = ({ as = 'div', ...props }) => {
|
export const Html: React.FC<HtmlProps> = ({ as = "div", ...props }) => {
|
||||||
return createElement(as, {
|
return createElement(as, {
|
||||||
className: props.className,
|
className: props.className,
|
||||||
dangerouslySetInnerHTML: {
|
dangerouslySetInnerHTML: {
|
||||||
__html: props.html,
|
__html: props.html,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import s from './title.module.css'
|
import s from "./title.module.css"
|
||||||
|
|
||||||
import { memo } from 'react'
|
import { memo } from "react"
|
||||||
|
|
||||||
export type HudozkaTitleProps = {
|
export type HudozkaTitleProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -13,3 +13,5 @@ export const HudozkaTitle: React.FC<HudozkaTitleProps> = memo(props => (
|
|||||||
<span className={s.suffix}>детская художественная школа</span>
|
<span className={s.suffix}>детская художественная школа</span>
|
||||||
</h1>
|
</h1>
|
||||||
))
|
))
|
||||||
|
|
||||||
|
HudozkaTitle.displayName = "HudozkaTitle"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import Link from 'next/link'
|
import Link from "next/link"
|
||||||
|
|
||||||
export interface ActiveLinkProps {
|
export interface ActiveLinkProps {
|
||||||
href?: string
|
href?: string
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from "next/router"
|
||||||
import { ActiveLink } from './ActiveLink'
|
import { ActiveLink } from "./ActiveLink"
|
||||||
import { isPartOfPath } from 'src/lib/url'
|
import { isPartOfPath } from "src/lib/url"
|
||||||
|
|
||||||
export type MenuItemProps = {
|
export type MenuItemProps = {
|
||||||
href: string
|
href: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MenuItem: React.FC<MenuItemProps> = props => {
|
export const MenuItem: React.FC<MenuItemProps> = props => {
|
||||||
const ignore = ['/']
|
const ignore = ["/"]
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const current = router.asPath === props.href
|
const current = router.asPath === props.href
|
||||||
const selected = current || (!ignore.includes(props.href) && isPartOfPath(props.href, router.asPath))
|
const selected = current || (!ignore.includes(props.href) && isPartOfPath(props.href, router.asPath))
|
||||||
const href = current ? null : props.href
|
const href = current ? undefined : props.href
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
@@ -24,7 +24,7 @@ export const MenuItem: React.FC<MenuItemProps> = props => {
|
|||||||
<ActiveLink
|
<ActiveLink
|
||||||
href={href}
|
href={href}
|
||||||
activeStyle={{
|
activeStyle={{
|
||||||
fontWeight: 'bold'
|
fontWeight: "bold",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { MenuItem } from './MenuItem'
|
import { MenuItem } from "./MenuItem"
|
||||||
import { IMenu } from 'src/types'
|
import { IMenu } from "src/types"
|
||||||
|
|
||||||
const layoutClass = {
|
const layoutClass = {
|
||||||
desktop: s.desktop,
|
desktop: s.desktop,
|
||||||
@@ -10,7 +10,7 @@ const layoutClass = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type MenuProps = {
|
export type MenuProps = {
|
||||||
layout: 'desktop' | 'mobile'
|
layout: "desktop" | "mobile"
|
||||||
items: IMenu[]
|
items: IMenu[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { Button } from '../Button'
|
import { Button } from "../Button"
|
||||||
|
|
||||||
export interface IMenuToggleProps {
|
export interface IMenuToggleProps {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -14,7 +14,7 @@ export const MenuToggle: React.FC<IMenuToggleProps> = props => {
|
|||||||
<Button
|
<Button
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
style={props.style}
|
style={props.style}
|
||||||
theme={'icon'}
|
theme={"icon"}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cx(s.toggle, {
|
className={cx(s.toggle, {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IMeta } from 'src/types'
|
import { IMeta } from "src/types"
|
||||||
|
|
||||||
export type MetaProps = {
|
export type MetaProps = {
|
||||||
meta: IMeta
|
meta: IMeta
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { MenuToggle } from '../MenuToggle'
|
import { MenuToggle } from "../MenuToggle"
|
||||||
import { useMobile } from 'src/hooks/useMobile'
|
import { useMobile } from "src/hooks/useMobile"
|
||||||
import { Menu } from '../Menu'
|
import { Menu } from "../Menu"
|
||||||
import { Overlay } from '../Overlay'
|
import { Overlay } from "../Overlay"
|
||||||
import { useState, useCallback, useContext } from 'react'
|
import { useState, useCallback, useContext } from "react"
|
||||||
import { ConfigContext } from 'src/context/ConfigContext'
|
import { ConfigContext } from "src/context/ConfigContext"
|
||||||
import { Block } from '../Block'
|
import { Block } from "../Block"
|
||||||
import { Spacer } from '../Spacer'
|
import { Spacer } from "../Spacer"
|
||||||
|
|
||||||
export interface INavigationProps {
|
export interface INavigationProps {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -28,24 +28,24 @@ export const Navigation: React.FC<INavigationProps> = props => {
|
|||||||
show={open}
|
show={open}
|
||||||
onClickOverlay={onClick}
|
onClickOverlay={onClick}
|
||||||
>
|
>
|
||||||
<Block direction={'horizontal'}>
|
<Block direction={"horizontal"}>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<MenuToggle
|
<MenuToggle
|
||||||
open={open}
|
open={open}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
style={{
|
style={{
|
||||||
margin: 'var(--size-xs)'
|
margin: "var(--size-xs)",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Block>
|
</Block>
|
||||||
<Block direction={'horizontal'} style={{
|
<Block direction={"horizontal"} style={{
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
}}>
|
}}>
|
||||||
<nav style={{
|
<nav style={{
|
||||||
width: '75%',
|
width: "75%",
|
||||||
}}>
|
}}>
|
||||||
<Menu
|
<Menu
|
||||||
layout={'mobile'}
|
layout={"mobile"}
|
||||||
items={menu}
|
items={menu}
|
||||||
/>
|
/>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -53,24 +53,24 @@ export const Navigation: React.FC<INavigationProps> = props => {
|
|||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
||||||
{collapseMenu ? (
|
{collapseMenu ? (
|
||||||
<Block direction={'horizontal'}>
|
<Block direction={"horizontal"}>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<MenuToggle
|
<MenuToggle
|
||||||
open={open}
|
open={open}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
style={{
|
style={{
|
||||||
margin: 'var(--size-xs)'
|
margin: "var(--size-xs)",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Block>
|
</Block>
|
||||||
) : (
|
) : (
|
||||||
<nav style={props.style}>
|
<nav style={props.style}>
|
||||||
<Menu
|
<Menu
|
||||||
layout={'desktop'}
|
layout={"desktop"}
|
||||||
items={menu}
|
items={menu}
|
||||||
/>
|
/>
|
||||||
</nav>
|
</nav>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
.section {
|
||||||
|
margin-top: var(--size-l);
|
||||||
|
margin-bottom: var(--size-l);
|
||||||
|
|
||||||
|
text-align: center;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section h1 {
|
||||||
|
font-size: 16pt;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section img {
|
||||||
|
margin-top: var(--size-m);
|
||||||
|
margin-bottom: var(--size-m);
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
@@ -1,34 +1,18 @@
|
|||||||
|
import s from "./error.module.css"
|
||||||
|
|
||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
export const NotFound: React.FC = () => (
|
export const NotFound: React.FC = () => (
|
||||||
<section>
|
<section className={s.section}>
|
||||||
<style jsx>{`
|
|
||||||
section {
|
|
||||||
margin-top: var(--size-l);
|
|
||||||
margin-bottom: var(--size-l);
|
|
||||||
|
|
||||||
text-align: center;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 16pt;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
margin-top: var(--size-m);
|
|
||||||
margin-bottom: var(--size-m);
|
|
||||||
max-width: 400px;
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h1>Страница не найдена.</h1>
|
<h1>Страница не найдена</h1>
|
||||||
<img src="/static/graphics/skull.jpg" />
|
<img src="/static/graphics/skull.jpg" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div><a href="/">На главную</a></div>
|
<div>
|
||||||
|
<Link href={"/"}>
|
||||||
|
<a>На главную</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as React from 'react'
|
import * as React from "react"
|
||||||
|
|
||||||
export interface ITransitionProps {
|
export interface ITransitionProps {
|
||||||
duration: number
|
duration: number
|
||||||
@@ -16,7 +16,8 @@ export const Transition: React.FC<ITransitionProps> = props => {
|
|||||||
}, [opacity])
|
}, [opacity])
|
||||||
const transition = React.useMemo(
|
const transition = React.useMemo(
|
||||||
() => `all ${props.duration}ms`,
|
() => `all ${props.duration}ms`,
|
||||||
[props.duration])
|
[props.duration]
|
||||||
|
)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!props.show) {
|
if (!props.show) {
|
||||||
@@ -34,7 +35,11 @@ export const Transition: React.FC<ITransitionProps> = props => {
|
|||||||
}
|
}
|
||||||
}, [props.show])
|
}, [props.show])
|
||||||
|
|
||||||
return mounted && (
|
if (!mounted) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
...props.extraStyle,
|
...props.extraStyle,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import { Transition } from './Transition'
|
import { Transition } from "./Transition"
|
||||||
import { useReducedMotion } from '../../hooks/useReducedMotion'
|
import { useReducedMotion } from "../../hooks/useReducedMotion"
|
||||||
import { useCallback, useEffect } from 'react'
|
import { useCallback, useEffect } from "react"
|
||||||
|
|
||||||
export interface IOverlayProps {
|
export interface IOverlayProps {
|
||||||
show: boolean
|
show: boolean
|
||||||
@@ -21,9 +21,9 @@ export const Overlay: React.FC<IOverlayProps> = props => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.show) {
|
if (props.show) {
|
||||||
document.body.classList.add('noscroll')
|
document.body.classList.add("noscroll")
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.remove('noscroll')
|
document.body.classList.remove("noscroll")
|
||||||
}
|
}
|
||||||
}, [props.show])
|
}, [props.show])
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import { PageMeta } from '../PageMeta'
|
import { PageMeta } from "../PageMeta"
|
||||||
import { ITag } from 'src/types'
|
import { ITag } from "src/types"
|
||||||
|
|
||||||
export type PageProps = {
|
export type PageProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -15,7 +15,7 @@ export const Page: React.FC<PageProps> = props => (
|
|||||||
|
|
||||||
<PageMeta
|
<PageMeta
|
||||||
style={{
|
style={{
|
||||||
marginTop: 'var(--size-m)',
|
marginTop: "var(--size-m)",
|
||||||
}}
|
}}
|
||||||
date={props.date}
|
date={props.date}
|
||||||
tags={props.tags}
|
tags={props.tags}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import s from './date.module.css'
|
import s from "./date.module.css"
|
||||||
|
|
||||||
import { dateFormat } from 'src/lib/date'
|
import { dateFormat } from "src/lib/date"
|
||||||
|
|
||||||
export type DateProps = {
|
export type DateProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import Image from 'next/image'
|
import Image from "next/image"
|
||||||
import { PageCardDto } from '@/types'
|
import { PageCardDto } from "@/types"
|
||||||
import { CardGrid } from '../CardGrid'
|
import { CardGrid } from "../CardGrid"
|
||||||
import { Card, CardLayout } from '../Card'
|
import { Card, CardLayout } from "../Card"
|
||||||
import { Date } from './Date'
|
import { Date } from "./Date"
|
||||||
import { Block } from '../Block'
|
import { Block } from "../Block"
|
||||||
import { Spacer } from '../Spacer'
|
import { Spacer } from "../Spacer"
|
||||||
|
|
||||||
export type PageGridProps = {
|
export type PageGridProps = {
|
||||||
items: PageCardDto[]
|
items: PageCardDto[]
|
||||||
@@ -14,23 +14,23 @@ export const PageGrid: React.FC<PageGridProps> = props => {
|
|||||||
return (
|
return (
|
||||||
<CardGrid
|
<CardGrid
|
||||||
style={{
|
style={{
|
||||||
marginBottom: 'var(--size-xl)',
|
marginBottom: "var(--size-xl)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.items.map(item => {
|
{props.items.map(item => {
|
||||||
const gridColumn = item.featured ? 'span 2' : 'auto'
|
const gridColumn = item.featured ? "span 2" : "auto"
|
||||||
const layout: CardLayout = item.featured ? 'featured' : 'simple'
|
const layout: CardLayout = item.featured ? "featured" : "simple"
|
||||||
|
|
||||||
const content = !item.featured
|
const content = !item.featured
|
||||||
? (
|
? (
|
||||||
<Block
|
<Block
|
||||||
direction={'vertical'}
|
direction={"vertical"}
|
||||||
>
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
<Spacer />
|
<Spacer />
|
||||||
{!item.date ? null : (
|
{!item.date ? null : (
|
||||||
<Date style={{
|
<Date style={{
|
||||||
marginTop: 'var(--size-m)',
|
marginTop: "var(--size-m)",
|
||||||
}}>{item.date}</Date>
|
}}>{item.date}</Date>
|
||||||
)}
|
)}
|
||||||
</Block>
|
</Block>
|
||||||
@@ -44,11 +44,11 @@ export const PageGrid: React.FC<PageGridProps> = props => {
|
|||||||
href={item.url}
|
href={item.url}
|
||||||
cover={(
|
cover={(
|
||||||
<Image
|
<Image
|
||||||
layout={'fill'}
|
layout={"fill"}
|
||||||
objectFit={'cover'}
|
objectFit={"cover"}
|
||||||
src={item.cover.src}
|
src={item.cover.src}
|
||||||
alt={item.cover.alt}
|
alt={item.cover.alt}
|
||||||
placeholder={'blur'}
|
placeholder={"blur"}
|
||||||
blurDataURL={item.cover.blur}
|
blurDataURL={item.cover.blur}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import s from './styles.module.css'
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
import { dateFormat } from 'src/lib/date'
|
import { dateFormat } from "src/lib/date"
|
||||||
import { ITag } from 'src/types'
|
import { ITag } from "src/types"
|
||||||
import { TagList, Direction } from '../TagList'
|
import { TagList, Direction } from "../TagList"
|
||||||
import { useMobile } from 'src/hooks/useMobile'
|
import { useMobile } from "src/hooks/useMobile"
|
||||||
|
|
||||||
export type PageMetaProps = {
|
export type PageMetaProps = {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -14,15 +14,15 @@ export type PageMetaProps = {
|
|||||||
|
|
||||||
export const PageMeta: React.FC<PageMetaProps> = props => {
|
export const PageMeta: React.FC<PageMetaProps> = props => {
|
||||||
const mobile = useMobile()
|
const mobile = useMobile()
|
||||||
const center = mobile ? null : 'center'
|
const center = mobile ? null : "center"
|
||||||
const direction: Direction = mobile ? 'vertical' : 'horizontal'
|
const direction: Direction = mobile ? "vertical" : "horizontal"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cx(s.pageMeta, {
|
<div className={cx(s.pageMeta, {
|
||||||
[s.center]: center,
|
[s.center]: center,
|
||||||
})} style={props.style}>
|
})} style={props.style}>
|
||||||
{!props.date ? null : (
|
{!props.date ? null : (
|
||||||
<p className={'date'}>Опубликовано {dateFormat(props.date)}</p>
|
<p className={"date"}>Опубликовано {dateFormat(props.date)}</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!(props.tags?.length) ? null : (
|
{!(props.tags?.length) ? null : (
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Block, BlockProps } from '../Block'
|
import { Block, BlockProps } from "../Block"
|
||||||
import { Button } from '../Button'
|
import { Button } from "../Button"
|
||||||
import { Spacer } from '../Spacer'
|
import { Spacer } from "../Spacer"
|
||||||
|
|
||||||
export type PagerProps = Omit<BlockProps, 'direction'> & {
|
export type PagerProps = Omit<BlockProps, "direction"> & {
|
||||||
nextHref: string | null
|
nextHref: string | null
|
||||||
prevHref: string | null
|
prevHref: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Pager: React.FC<PagerProps> = ({ prevHref, nextHref, ...props }) => (
|
export const Pager: React.FC<PagerProps> = ({ prevHref, nextHref, ...props }) => (
|
||||||
<Block {...props} direction={'horizontal'}>
|
<Block {...props} direction={"horizontal"}>
|
||||||
{!prevHref ? null : (
|
{!prevHref ? null : (
|
||||||
<Button href={prevHref}>Предыдущая страница</Button>
|
<Button href={prevHref}>Предыдущая страница</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
import s from './picture.module.css'
|
import s from "./picture.module.css"
|
||||||
|
|
||||||
import { memo } from 'react'
|
import { memo } from "react"
|
||||||
import Image from 'next/image'
|
import Image from "next/image"
|
||||||
import { Pic } from '@/types'
|
import { Pic } from "@/types"
|
||||||
|
|
||||||
const modifiers = new Map([
|
const modifiers = new Map([
|
||||||
['square', s.square],
|
["square", s.square],
|
||||||
['vertical', s.vertical],
|
["vertical", s.vertical],
|
||||||
['horizontal', ''],
|
["horizontal", ""],
|
||||||
])
|
])
|
||||||
|
|
||||||
function size(w: number, h: number, tolerance: number) {
|
function size(w: number, h: number, tolerance: number) {
|
||||||
const r = w / h
|
const r = w / h
|
||||||
if (r < 1 && r > tolerance) {
|
if (r < 1 && r > tolerance) {
|
||||||
return 'square'
|
return "square"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w < h) {
|
if (w < h) {
|
||||||
return 'vertical'
|
return "vertical"
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'horizontal'
|
return "horizontal"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PictureProps = Pic & {
|
export type PictureProps = Pic & {
|
||||||
@@ -31,19 +31,19 @@ export type PictureProps = Pic & {
|
|||||||
export const Picture: React.FC<PictureProps> = memo(({ wide = false, ...props }) => {
|
export const Picture: React.FC<PictureProps> = memo(({ wide = false, ...props }) => {
|
||||||
const ss = size(props.width, props.height, 0.95)
|
const ss = size(props.width, props.height, 0.95)
|
||||||
const layout = modifiers.get(ss)
|
const layout = modifiers.get(ss)
|
||||||
const w = ss === 'horizontal' ? wide : false
|
const w = ss === "horizontal" ? wide : false
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<figure className={`${s.pic} ${layout} ${w ? s.wide : ''}`}>
|
<figure className={`${s.pic} ${layout} ${w ? s.wide : ""}`}>
|
||||||
<Image
|
<Image
|
||||||
className={s.img}
|
className={s.img}
|
||||||
src={props.src}
|
src={props.src}
|
||||||
alt={props.alt}
|
alt={props.alt}
|
||||||
width={props.width}
|
width={props.width}
|
||||||
height={props.height}
|
height={props.height}
|
||||||
layout={'responsive'}
|
layout={"responsive"}
|
||||||
blurDataURL={props.blur}
|
blurDataURL={props.blur}
|
||||||
placeholder={'blur'}
|
placeholder={"blur"}
|
||||||
/>
|
/>
|
||||||
{!props.caption ? null : (
|
{!props.caption ? null : (
|
||||||
<figcaption>{props.caption}</figcaption>
|
<figcaption>{props.caption}</figcaption>
|
||||||
@@ -51,3 +51,5 @@ export const Picture: React.FC<PictureProps> = memo(({ wide = false, ...props })
|
|||||||
</figure>
|
</figure>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Picture.displayName = "Picture"
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import * as React from 'react'
|
|
||||||
|
|
||||||
export const Share: React.FC = () => (
|
export const Share: React.FC = () => (
|
||||||
<div className="likely">
|
<div className="likely">
|
||||||
<div className="vkontakte">Поделиться</div>
|
<div className="vkontakte">Поделиться</div>
|
||||||
<div className="facebook">Поделиться</div>
|
<div className="facebook">Поделиться</div>
|
||||||
<div className="telegram">Отправить</div>
|
<div className="telegram">Отправить</div>
|
||||||
<div className="twitter">Твитнуть</div>
|
<div className="twitter">Твитнуть</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { createElement } from 'react'
|
import { createElement } from "react"
|
||||||
|
|
||||||
export type SpacerProps = {
|
export type SpacerProps = {
|
||||||
as?: keyof HTMLElementTagNameMap
|
as?: keyof HTMLElementTagNameMap
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Spacer: React.FC<SpacerProps> = ({ as = 'div' }) => createElement(as, {
|
export const Spacer: React.FC<SpacerProps> = ({ as = "div" }) => createElement(as, {
|
||||||
style: {
|
style: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import s from './wrapper.module.css'
|
import s from "./wrapper.module.css"
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from "classnames"
|
||||||
|
|
||||||
export type WrapperProps = {
|
export type WrapperProps = {
|
||||||
header: React.ReactNode
|
header: React.ReactNode
|
||||||
@@ -10,7 +10,7 @@ export type WrapperProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Wrapper: React.FC<WrapperProps> = props => (
|
export const Wrapper: React.FC<WrapperProps> = props => (
|
||||||
<div className={cx(s.container, 'theme-default')} style={props.style}>
|
<div className={cx(s.container, "theme-default")} style={props.style}>
|
||||||
{props.header}
|
{props.header}
|
||||||
|
|
||||||
<main className={s.main} style={props.mainStyle}>
|
<main className={s.main} style={props.mainStyle}>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React from "react"
|
||||||
|
|
||||||
function script(account) {
|
function script(account) {
|
||||||
return `
|
return `
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export type YoutubeProps = {
|
|||||||
|
|
||||||
export const Youtube: React.FC<{ url: string }> = props => {
|
export const Youtube: React.FC<{ url: string }> = props => {
|
||||||
const url = new URL(props.url)
|
const url = new URL(props.url)
|
||||||
const videoId = url.searchParams.get('v')
|
const videoId = url.searchParams.get("v")
|
||||||
if (!videoId) {
|
if (!videoId) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-38
@@ -1,72 +1,74 @@
|
|||||||
const currentYear = () => (new Date()).getFullYear()
|
const currentYear = () => (new Date()).getFullYear()
|
||||||
|
|
||||||
export default {
|
const config = {
|
||||||
yearStart: 2012,
|
yearStart: 2012,
|
||||||
yearEnd: currentYear(),
|
yearEnd: currentYear(),
|
||||||
contacts: [
|
contacts: [
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: "link",
|
||||||
value: 'https://yandex.ru/maps/-/CKUkAXIb',
|
value: "https://yandex.ru/maps/-/CKUkAXIb",
|
||||||
title: 'г. Шлиссельбург ул. 18 января д. 3',
|
title: "г. Шлиссельбург ул. 18 января д. 3",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'tel',
|
type: "tel",
|
||||||
value: 'tel:+78136276312',
|
value: "tel:+78136276312",
|
||||||
title: '+7 (81362) 76-312',
|
title: "+7 (81362) 76-312",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'email',
|
type: "email",
|
||||||
value: 'mailto:hudozka@gmail.com',
|
value: "mailto:hudozka@gmail.com",
|
||||||
title: 'hudozka@gmail.com',
|
title: "hudozka@gmail.com",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: "link",
|
||||||
value: 'https://clck.ru/H83zS',
|
value: "https://clck.ru/H83zS",
|
||||||
title: 'Навигатор дополнительного образования ЛО',
|
title: "Навигатор дополнительного образования ЛО",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: "link",
|
||||||
value: 'https://vk.com/shlisselburghudozka',
|
value: "https://vk.com/shlisselburghudozka",
|
||||||
title: 'Вконтакте'
|
title: "Вконтакте",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'link',
|
type: "link",
|
||||||
value: 'https://www.instagram.com/hudozka',
|
value: "https://www.instagram.com/hudozka",
|
||||||
title: 'Инстаграм'
|
title: "Инстаграм",
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
menu: [
|
menu: [
|
||||||
{
|
{
|
||||||
name: 'Школа',
|
name: "Школа",
|
||||||
href: '/',
|
href: "/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Поступление',
|
name: "Поступление",
|
||||||
href: '/join',
|
href: "/join",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Предметы',
|
name: "Предметы",
|
||||||
href: '/courses',
|
href: "/courses",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Коллектив',
|
name: "Коллектив",
|
||||||
href: '/collective',
|
href: "/collective",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '«Мы соседи»',
|
name: "«Мы соседи»",
|
||||||
href: '/neighbors',
|
href: "/neighbors",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Документы',
|
name: "Документы",
|
||||||
href: '/documents',
|
href: "/documents",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Сведения об образовательной организации',
|
name: "Сведения об образовательной организации",
|
||||||
href: '/info',
|
href: "/info",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Дистанционное образование',
|
name: "Дистанционное образование",
|
||||||
href: '/info/online-education',
|
href: "/info/online-education",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default config
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createContext } from 'react'
|
import { createContext } from "react"
|
||||||
import config from 'src/config'
|
import config from "src/config"
|
||||||
|
|
||||||
export const ConfigContext = createContext(config)
|
export const ConfigContext = createContext(config)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import useMedia from 'use-media'
|
import useMedia from "use-media"
|
||||||
|
|
||||||
export function useMobile(): boolean {
|
export function useMobile(): boolean {
|
||||||
return useMedia('(max-width: 31.25em)', false)
|
return useMedia("(max-width: 31.25em)", false)
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import useMedia from 'use-media'
|
import useMedia from "use-media"
|
||||||
|
|
||||||
export function useReducedMotion(): boolean {
|
export function useReducedMotion(): boolean {
|
||||||
return useMedia('(prefers-reduced-motion: reduce)')
|
return useMedia("(prefers-reduced-motion: reduce)")
|
||||||
}
|
}
|
||||||
+3
-12
@@ -1,16 +1,7 @@
|
|||||||
export function splitBy(fn) {
|
export type InsertBetweenFunction<T> = (i: number) => T
|
||||||
return items => {
|
|
||||||
return items.reduce((acc, item) => {
|
|
||||||
const key = fn(item)
|
|
||||||
const items = acc.get(key) || []
|
|
||||||
|
|
||||||
return acc.set(key, [...items, item])
|
export function insertBetween<T, I = T>(items: T[], fn: InsertBetweenFunction<I>): Array<T | I> {
|
||||||
}, new Map())
|
return items.reduce<Array<T | I>>((acc, x, i) => {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function insertBetween<T, I = T>(items: T[], fn: (i: number) => I): Array<T | I> {
|
|
||||||
return items.reduce((acc, x, i) => {
|
|
||||||
acc.push(x)
|
acc.push(x)
|
||||||
|
|
||||||
if (i < items.length - 1) {
|
if (i < items.length - 1) {
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import format from 'date-fns/format'
|
import format from "date-fns/format"
|
||||||
import { ru } from 'date-fns/locale'
|
import { ru } from "date-fns/locale"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -8,8 +8,8 @@ import { ru } from 'date-fns/locale'
|
|||||||
* @param date
|
* @param date
|
||||||
*/
|
*/
|
||||||
export const dateFormat = (date: string | Date) => {
|
export const dateFormat = (date: string | Date) => {
|
||||||
const value = typeof date === 'string' ? new Date(date) : date
|
const value = typeof date === "string" ? new Date(date) : date
|
||||||
return format(value, "d MMMM yyyy", {
|
return format(value, "d MMMM yyyy", {
|
||||||
locale: ru
|
locale: ru,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
+6
-6
@@ -1,21 +1,21 @@
|
|||||||
const units = ['байт', 'КБ', 'МБ', 'ГБ', 'ТБ', 'ПБ']
|
const units = ["байт", "КБ", "МБ", "ГБ", "ТБ", "ПБ"]
|
||||||
|
|
||||||
const mime = new Map([
|
const mime = new Map([
|
||||||
['application/pdf', 'ПДФ'],
|
["application/pdf", "ПДФ"],
|
||||||
['image/jpeg', 'ЖПГ'],
|
["image/jpeg", "ЖПГ"],
|
||||||
['image/png', 'ПНГ'],
|
["image/png", "ПНГ"],
|
||||||
])
|
])
|
||||||
|
|
||||||
export function ext(mimeType: string): string {
|
export function ext(mimeType: string): string {
|
||||||
if (mime.has(mimeType)) {
|
if (mime.has(mimeType)) {
|
||||||
return mime.get(mimeType)
|
return mime.get(mimeType)!
|
||||||
}
|
}
|
||||||
|
|
||||||
return mimeType
|
return mimeType
|
||||||
}
|
}
|
||||||
|
|
||||||
export function size(bytes: any, precision = 1): string {
|
export function size(bytes: any, precision = 1): string {
|
||||||
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return ''
|
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return ""
|
||||||
|
|
||||||
const number = Math.floor(Math.log(bytes) / Math.log(1024))
|
const number = Math.floor(Math.log(bytes) / Math.log(1024))
|
||||||
const size = (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision)
|
const size = (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision)
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ export type ResizeOptions = {
|
|||||||
|
|
||||||
export function getResizedUrl(src: string, options: ResizeOptions): string {
|
export function getResizedUrl(src: string, options: ResizeOptions): string {
|
||||||
const n = options.n ?? 1
|
const n = options.n ?? 1
|
||||||
if (!src || src === '') {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return `https://images.weserv.nl/?url=${src}&w=${options.width}&h=${options.height}&n=${n}`
|
return `https://images.weserv.nl/?url=${src}&w=${options.width}&h=${options.height}&n=${n}`
|
||||||
}
|
}
|
||||||
+25
-18
@@ -1,23 +1,23 @@
|
|||||||
import { IMeta, Pic } from 'src/types'
|
import { IMeta, Pic } from "src/types"
|
||||||
|
|
||||||
export function meta(props: Partial<IMeta>): IMeta {
|
export function meta(props: Partial<IMeta>): IMeta {
|
||||||
const path = props.url || '/'
|
const path = props.url || "/"
|
||||||
const url = `https://art.shlisselburg.org${path}`
|
const url = `https://art.shlisselburg.org${path}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: 'Шлиссельбургская ДХШ',
|
title: "Шлиссельбургская ДХШ",
|
||||||
description: 'Сайт Шлиссельбургской художественной школы',
|
description: "Сайт Шлиссельбургской художественной школы",
|
||||||
image: 'https://art.shlisselburg.org/entrance.jpg',
|
image: "https://art.shlisselburg.org/entrance.jpg",
|
||||||
imageWidth: 1200,
|
imageWidth: 1200,
|
||||||
imageHeight: 630,
|
imageHeight: 630,
|
||||||
|
|
||||||
siteName: 'Шлиссельбургская Детская Художественная Школа',
|
siteName: "Шлиссельбургская Детская Художественная Школа",
|
||||||
locale: 'ru_RU',
|
locale: "ru_RU",
|
||||||
type: 'website',
|
type: "website",
|
||||||
domain: 'art.shlisselburg.org',
|
domain: "art.shlisselburg.org",
|
||||||
twitterCard: 'summary_large_image',
|
twitterCard: "summary_large_image",
|
||||||
twitterSite: '@',
|
twitterSite: "@",
|
||||||
twitterCreator: '@tmshv',
|
twitterCreator: "@tmshv",
|
||||||
|
|
||||||
...props,
|
...props,
|
||||||
url,
|
url,
|
||||||
@@ -25,10 +25,10 @@ export function meta(props: Partial<IMeta>): IMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MetaBuilder {
|
export class MetaBuilder {
|
||||||
private image: Pic
|
private image?: Pic
|
||||||
private title: string
|
private title?: string
|
||||||
private description: string
|
private description?: string
|
||||||
private data: Partial<IMeta>
|
private data?: Partial<IMeta>
|
||||||
|
|
||||||
setData(param: Partial<IMeta>) {
|
setData(param: Partial<IMeta>) {
|
||||||
this.data = param
|
this.data = param
|
||||||
@@ -53,11 +53,18 @@ export class MetaBuilder {
|
|||||||
build() {
|
build() {
|
||||||
const image = this.buildImage()
|
const image = this.buildImage()
|
||||||
|
|
||||||
|
const params: Record<string, string> = {}
|
||||||
|
if (this.title) {
|
||||||
|
params.title = this.title
|
||||||
|
}
|
||||||
|
if (this.description) {
|
||||||
|
params.description = this.description
|
||||||
|
}
|
||||||
|
|
||||||
return meta({
|
return meta({
|
||||||
...this.data,
|
...this.data,
|
||||||
...image,
|
...image,
|
||||||
title: this.title ?? null,
|
...params,
|
||||||
description: this.description ?? null,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
export function titleCase(str: string) {
|
export function titleCase(str: string) {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
import MarkdownIt from 'markdown-it'
|
import MarkdownIt from "markdown-it"
|
||||||
import Typograf from 'typograf'
|
import Typograf from "typograf"
|
||||||
|
|
||||||
const tp = new Typograf({ locale: ['ru'] })
|
const tp = new Typograf({ locale: ["ru"] })
|
||||||
const md = new MarkdownIt({
|
const md = new MarkdownIt({
|
||||||
html: true,
|
html: true,
|
||||||
})
|
})
|
||||||
|
|||||||
+2
-2
@@ -4,10 +4,10 @@ export function isPartOfPath(part: string, path: string): boolean {
|
|||||||
|
|
||||||
export function queryList(key: string, values: string[]): string {
|
export function queryList(key: string, values: string[]): string {
|
||||||
if (values.length === 0) {
|
if (values.length === 0) {
|
||||||
return ''
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return values
|
return values
|
||||||
.map(value => `${key}=${value}`)
|
.map(value => `${key}=${value}`)
|
||||||
.join('&')
|
.join("&")
|
||||||
}
|
}
|
||||||
+3
-18
@@ -1,5 +1,4 @@
|
|||||||
import axios from 'axios'
|
import { NextPageContext } from "next"
|
||||||
import { NextPageContext } from 'next'
|
|
||||||
|
|
||||||
export interface IResponseItems<T> {
|
export interface IResponseItems<T> {
|
||||||
items: T[]
|
items: T[]
|
||||||
@@ -7,16 +6,6 @@ export interface IResponseItems<T> {
|
|||||||
prevPage: number
|
prevPage: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function requestGet<T>(url: string, defaultResponse: T): Promise<T> {
|
|
||||||
try {
|
|
||||||
const res = await axios.get<T>(url)
|
|
||||||
|
|
||||||
return res.data
|
|
||||||
} catch (e) {
|
|
||||||
return defaultResponse
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This wrapper prevents fetching api request in static export mode and production environment
|
* This wrapper prevents fetching api request in static export mode and production environment
|
||||||
* because nextjs call getInitialProps on the client side
|
* because nextjs call getInitialProps on the client side
|
||||||
@@ -25,18 +14,14 @@ export async function requestGet<T>(url: string, defaultResponse: T): Promise<T>
|
|||||||
*/
|
*/
|
||||||
export function wrapInitialProps(fn: (ctx: NextPageContext) => void) {
|
export function wrapInitialProps(fn: (ctx: NextPageContext) => void) {
|
||||||
return async (ctx: NextPageContext) => {
|
return async (ctx: NextPageContext) => {
|
||||||
if (process.env.NODE_ENV === 'production' && process.browser) {
|
if (process.env.NODE_ENV === "production" && process.browser) {
|
||||||
return window['__NEXT_DATA__'].props.pageProps;
|
return window["__NEXT_DATA__"].props.pageProps
|
||||||
}
|
}
|
||||||
|
|
||||||
return fn(ctx)
|
return fn(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createApiUrl(path: string) {
|
|
||||||
return `https://api.tmshv.com/hudozka${path}`
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FactoryFunction<I, O> =
|
export type FactoryFunction<I, O> =
|
||||||
| ((response: I) => O)
|
| ((response: I) => O)
|
||||||
| ((response: I) => Promise<O>)
|
| ((response: I) => Promise<O>)
|
||||||
|
|||||||
+63
-63
@@ -1,8 +1,8 @@
|
|||||||
import { IMenu, IPage, ITag, PageCardDto, Pic, Token } from "@/types";
|
import { IMenu, IPage, ITag, PageCardDto, Pic, Token } from "@/types"
|
||||||
import { asItem } from "./lib";
|
import { asItem } from "./lib"
|
||||||
import { StrapiComponentEmbed, StrapiComponent, StrapiHome, StrapiPage, StrapiPageCard, StrapiTag, StrapiMedia, StrapiMenu } from "./types";
|
import { StrapiComponentEmbed, StrapiComponent, StrapiHome, StrapiPage, StrapiPageCard, StrapiTag, StrapiMedia, StrapiMenu } from "./types"
|
||||||
import { typograf, markdownToHtml } from 'src/lib/text'
|
import { typograf, markdownToHtml } from "src/lib/text"
|
||||||
import { encodeImageToBlurhash } from "./image";
|
import { encodeImageToBlurhash } from "./image"
|
||||||
|
|
||||||
const md = (text: string) => typograf(markdownToHtml(text))
|
const md = (text: string) => typograf(markdownToHtml(text))
|
||||||
|
|
||||||
@@ -19,79 +19,79 @@ export function isYoutubeUrl(url: string): boolean {
|
|||||||
export function createEmbed(component: StrapiComponentEmbed): Token {
|
export function createEmbed(component: StrapiComponentEmbed): Token {
|
||||||
if (isYoutubeUrl(component.src)) {
|
if (isYoutubeUrl(component.src)) {
|
||||||
return {
|
return {
|
||||||
token: 'youtube',
|
token: "youtube",
|
||||||
data: {
|
data: {
|
||||||
url: component.src,
|
url: component.src,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
token: 'html',
|
token: "html",
|
||||||
data: `<iframe src="${component.src}" width="100%" height="480" frameborder="0"></iframe>`
|
data: `<iframe src="${component.src}" width="100%" height="480" frameborder="0"></iframe>`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createPageToken(component: StrapiComponent): Promise<Token> {
|
export async function createPageToken(component: StrapiComponent): Promise<Token> {
|
||||||
switch (component.__component) {
|
switch (component.__component) {
|
||||||
case 'hudozka.text': {
|
case "hudozka.text": {
|
||||||
return {
|
return {
|
||||||
token: 'html',
|
token: "html",
|
||||||
data: md(component.text),
|
data: md(component.text),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'hudozka.image': {
|
case "hudozka.image": {
|
||||||
const data = await createPicFromMedia(component.media, {
|
const data = await createPicFromMedia(component.media, {
|
||||||
alternativeText: component.caption,
|
alternativeText: component.caption,
|
||||||
caption: component.caption,
|
caption: component.caption,
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
token: 'image',
|
token: "image",
|
||||||
wide: component.wide,
|
wide: component.wide,
|
||||||
data,
|
data,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'hudozka.document': {
|
case "hudozka.document": {
|
||||||
return {
|
return {
|
||||||
token: 'file',
|
token: "file",
|
||||||
data: {
|
data: {
|
||||||
url: component.media.url,
|
url: component.media.url,
|
||||||
slug: 'jopa',
|
slug: "jopa",
|
||||||
image_url: component.media.url,
|
image_url: component.media.url,
|
||||||
file_url: component.media.url,
|
file_url: component.media.url,
|
||||||
title: component.title,
|
title: component.title,
|
||||||
file_size: component.media.size * 1000,
|
file_size: component.media.size * 1000,
|
||||||
// file_size: component.media.size,
|
// file_size: component.media.size,
|
||||||
file_format: component.media.mime,
|
file_format: component.media.mime,
|
||||||
}
|
},
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'hudozka.embed': {
|
case "hudozka.embed": {
|
||||||
return createEmbed(component)
|
return createEmbed(component)
|
||||||
|
}
|
||||||
|
|
||||||
|
case "hudozka.card-grid": {
|
||||||
|
const items = await Promise.all(component.items
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(createCardGrid)
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
token: "grid",
|
||||||
|
data: {
|
||||||
|
items,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'hudozka.card-grid': {
|
default:
|
||||||
const items = await Promise.all(component.items
|
return {
|
||||||
.filter(Boolean)
|
token: "text",
|
||||||
.map(createCardGrid)
|
data: ` ${JSON.stringify(component)}`,
|
||||||
)
|
|
||||||
return {
|
|
||||||
token: 'grid',
|
|
||||||
data: {
|
|
||||||
items,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
|
||||||
return {
|
|
||||||
token: 'text',
|
|
||||||
data: ` ${JSON.stringify(component)}`,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ export function createMenu(res: StrapiMenu): IMenu[] {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
href: '/',
|
href: "/",
|
||||||
name: res.homeLabel,
|
name: res.homeLabel,
|
||||||
}, ...items]
|
}, ...items]
|
||||||
}
|
}
|
||||||
@@ -130,12 +130,12 @@ export async function createPage(res: StrapiPage | StrapiPage[]): Promise<IPage
|
|||||||
id: `${item.id}`,
|
id: `${item.id}`,
|
||||||
url: item.slug,
|
url: item.slug,
|
||||||
|
|
||||||
data: '',
|
data: "",
|
||||||
date: '',
|
date: "",
|
||||||
cover,
|
cover,
|
||||||
tokens: [
|
tokens: [
|
||||||
{
|
{
|
||||||
token: 'html',
|
token: "html",
|
||||||
data: md(`# ${item.title}`),
|
data: md(`# ${item.title}`),
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ export async function createPage(res: StrapiPage | StrapiPage[]): Promise<IPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isCardFeatured(card: StrapiPageCard): boolean {
|
function isCardFeatured(card: StrapiPageCard): boolean {
|
||||||
return card.layout === 'big' || card.layout === 'medium'
|
return card.layout === "big" || card.layout === "medium"
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCoverImage(media?: StrapiMedia): Promise<Pic> {
|
export async function getCoverImage(media?: StrapiMedia): Promise<Pic> {
|
||||||
@@ -157,7 +157,7 @@ export async function getCoverImage(media?: StrapiMedia): Promise<Pic> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
src: 'https://hudozkacdn.tmshv.com/main_fad9fdf29a.jpg',
|
src: "https://hudozkacdn.tmshv.com/main_fad9fdf29a.jpg",
|
||||||
width: 1920,
|
width: 1920,
|
||||||
height: 1858,
|
height: 1858,
|
||||||
// alt: '',
|
// alt: '',
|
||||||
|
|||||||
+18
-8
@@ -1,20 +1,30 @@
|
|||||||
import sharp from "sharp"
|
import sharp from "sharp"
|
||||||
|
|
||||||
export async function encodeImageToBlurhash(url: string) {
|
async function fetchBuffer(url: string) {
|
||||||
const res = await fetch(url)
|
try {
|
||||||
if (!res.ok) {
|
const res = await fetch(url)
|
||||||
|
if (!res.ok) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const data = await res.arrayBuffer()
|
||||||
|
return Buffer.from(data)
|
||||||
|
} catch (error) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const data = await res.arrayBuffer()
|
export async function encodeImageToBlurhash(url: string) {
|
||||||
const buffer = Buffer.from(data)
|
const buffer = await fetchBuffer(url)
|
||||||
|
if (!buffer) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
const t = sharp(buffer)
|
const t = sharp(buffer)
|
||||||
.raw()
|
.raw()
|
||||||
.resize(8, 8, { fit: "inside" })
|
.resize(8, 8, { fit: "inside" })
|
||||||
.toFormat('jpeg')
|
.toFormat("jpeg")
|
||||||
|
|
||||||
const { data: out, info } = await t.toBuffer({ resolveWithObject: true })
|
const { data } = await t.toBuffer({ resolveWithObject: true })
|
||||||
|
|
||||||
return `data:image/jpeg;base64,${out.toString('base64')}`
|
return `data:image/jpeg;base64,${data.toString("base64")}`
|
||||||
}
|
}
|
||||||
+1
-1
@@ -11,7 +11,7 @@ export function asItem<T>(value: T | T[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function paramsToSlug(parts: string | string[]): string {
|
export function paramsToSlug(parts: string | string[]): string {
|
||||||
const slug = asArray(parts).join('/')
|
const slug = asArray(parts).join("/")
|
||||||
|
|
||||||
return `/${slug}`
|
return `/${slug}`
|
||||||
}
|
}
|
||||||
+2
-2
@@ -128,8 +128,8 @@ export type StrapiMenu = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type StrapiPageCard = {
|
export type StrapiPageCard = {
|
||||||
__component: 'hudozka.page-card',
|
__component: "hudozka.page-card",
|
||||||
id: number,
|
id: number,
|
||||||
page: StrapiPage,
|
page: StrapiPage,
|
||||||
layout: 'small' | 'medium' | 'big',
|
layout: "small" | "medium" | "big",
|
||||||
}
|
}
|
||||||
+7
-7
@@ -102,12 +102,12 @@ export type Pic = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type TextToken = {
|
export type TextToken = {
|
||||||
token: 'text'
|
token: "text"
|
||||||
data: string
|
data: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ImageToken = {
|
export type ImageToken = {
|
||||||
token: 'image'
|
token: "image"
|
||||||
wide: boolean
|
wide: boolean
|
||||||
data: Pic
|
data: Pic
|
||||||
}
|
}
|
||||||
@@ -123,24 +123,24 @@ export type FileTokenData = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type FileToken = {
|
export type FileToken = {
|
||||||
token: 'file'
|
token: "file"
|
||||||
data: FileTokenData
|
data: FileTokenData
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HtmlToken = {
|
export type HtmlToken = {
|
||||||
token: 'html'
|
token: "html"
|
||||||
data: string
|
data: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type YoutubeToken = {
|
export type YoutubeToken = {
|
||||||
token: 'youtube'
|
token: "youtube"
|
||||||
data: {
|
data: {
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InstagramToken = {
|
export type InstagramToken = {
|
||||||
token: 'instagram'
|
token: "instagram"
|
||||||
data: {
|
data: {
|
||||||
url: string
|
url: string
|
||||||
embed: string
|
embed: string
|
||||||
@@ -148,7 +148,7 @@ export type InstagramToken = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type GridToken = {
|
export type GridToken = {
|
||||||
token: 'grid'
|
token: "grid"
|
||||||
data: {
|
data: {
|
||||||
items: PageCardDto[]
|
items: PageCardDto[]
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -2,9 +2,9 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": [
|
"@/*": [
|
||||||
"src/*"
|
"src/*"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"lib": [
|
"lib": [
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
],
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": false,
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|||||||
Reference in new issue
Block a user