double qutes eslint rule

This commit is contained in:
tmshv committed 2022-09-06 14:52:56 +03:00
1 parent 2e517cc7f7
commit 85bc8c4af5
57 files changed
+370 -366

No files matched your search

+4
View File
@@ -10,6 +10,10 @@
"error", "error",
"always-multiline" "always-multiline"
], ],
"quotes": [
"error",
"double"
],
"no-tabs": "off", "no-tabs": "off",
"indent": [ "indent": [
"warn", "warn",
+32 -32
View File
@@ -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,10 +76,10 @@ 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}
@@ -87,7 +87,7 @@ const Index: NextPage<Props> = props => {
/> />
) )
case 'instagram': case "instagram":
return ( return (
<Html <Html
key={i} key={i}
@@ -95,7 +95,7 @@ const Index: NextPage<Props> = props => {
/> />
) )
case 'youtube': case "youtube":
return ( return (
<Youtube <Youtube
key={i} key={i}
@@ -103,7 +103,7 @@ const Index: NextPage<Props> = props => {
/> />
) )
case 'image': case "image":
return ( return (
<Picture <Picture
key={i} key={i}
@@ -117,7 +117,7 @@ const Index: NextPage<Props> = props => {
/> />
) )
case 'file': case "file":
return ( return (
<FileCard <FileCard
key={i} key={i}
@@ -126,7 +126,7 @@ const Index: NextPage<Props> = props => {
/> />
) )
case 'grid': case "grid":
return ( return (
<PageGrid <PageGrid
key={i} key={i}
@@ -158,7 +158,7 @@ export const getStaticProps: GetStaticProps<Props> = async ctx => {
} }
} }
const menu = await apiGet(createMenu)('https://hudozka.tmshv.com/menu', () => []) const menu = await apiGet(createMenu)("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
@@ -181,10 +181,10 @@ 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",
}, },
}, },
} }
@@ -197,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 -10
View File
@@ -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() {
@@ -39,7 +39,7 @@ export default class MyApp extends App {
/> />
<YMetrika account={24027460} /> <YMetrika account={24027460} />
<GAnalytics account={'UA-60209057-1'} /> <GAnalytics account={"UA-60209057-1"} />
</Head> </Head>
<Component {...pageProps} /> <Component {...pageProps} />
</> </>
+1 -1
View File
@@ -1,4 +1,4 @@
import { Html, Head, Main, NextScript } from 'next/document' import { Html, Head, Main, NextScript } from "next/document"
export default function Document() { export default function Document() {
return ( return (
+8 -8
View File
@@ -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 -16
View File
@@ -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,14 +40,14 @@ const Index: NextPage<Props> = props => (
) )
export const getStaticProps: GetStaticProps<Props> = async () => { export const getStaticProps: GetStaticProps<Props> = async () => {
const items = await apiGet(createHomeCards)('https://hudozka.tmshv.com/home', async () => []) const items = await apiGet(createHomeCards)("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()
+19 -19
View File
@@ -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>
+6 -6
View File
@@ -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 = {
+9 -9
View File
@@ -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}
+8 -8
View File
@@ -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,
}) })
+4 -4
View File
@@ -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 -1
View File
@@ -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
+4 -4
View File
@@ -1,8 +1,8 @@
import s from './contacts.module.css' import s from "./contacts.module.css"
import { useContext } from 'react' import { useContext } from "react"
import { ConfigContext } from 'src/context/ConfigContext' import { ConfigContext } from "src/context/ConfigContext"
import Link from 'next/link' 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)
+4 -4
View File
@@ -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}
> >
+2 -2
View File
@@ -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)
+6 -6
View File
@@ -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>
) )
+9 -9
View File
@@ -1,11 +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' import Link from "next/link"
export type FileCardProps = FileTokenData & { export type FileCardProps = FileTokenData & {
sign?: Sign sign?: Sign
@@ -29,10 +29,10 @@ export const FileCard: React.FC<FileCardProps> = props => {
}) })
}} }}
src={props.image_url} src={props.image_url}
alt={''} alt={""}
width={100} width={100}
height={100} height={100}
objectFit={'contain'} objectFit={"contain"}
/> />
</div> </div>
</a> </a>
+4 -4
View File
@@ -1,8 +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' import Link from "next/link"
export type FileProps = FileDefinition & { export type FileProps = FileDefinition & {
style?: React.CSSProperties style?: React.CSSProperties
+12 -12
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import React from 'react' import React from "react"
function script(account) { function script(account) {
return ` return `
+3 -3
View File
@@ -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 (
+2 -2
View File
@@ -1,4 +1,4 @@
import { createElement } from 'react' import { createElement } from "react"
export type HtmlProps = { export type HtmlProps = {
className?: string className?: string
@@ -6,7 +6,7 @@ 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: {
+3 -3
View File
@@ -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
@@ -14,4 +14,4 @@ export const HudozkaTitle: React.FC<HudozkaTitleProps> = memo(props => (
</h1> </h1>
)) ))
HudozkaTitle.displayName = 'HudozkaTitle' HudozkaTitle.displayName = "HudozkaTitle"
+1 -1
View File
@@ -1,4 +1,4 @@
import Link from 'next/link' import Link from "next/link"
export interface ActiveLinkProps { export interface ActiveLinkProps {
href?: string href?: string
+7 -7
View File
@@ -1,15 +1,15 @@
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))
@@ -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}
+5 -5
View File
@@ -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[]
} }
+4 -4
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import { IMeta } from 'src/types' import { IMeta } from "src/types"
export type MetaProps = { export type MetaProps = {
meta: IMeta meta: IMeta
+17 -17
View File
@@ -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,20 +53,20 @@ 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>
+3 -3
View File
@@ -1,6 +1,6 @@
import s from './error.module.css' import s from "./error.module.css"
import Link from 'next/link' import Link from "next/link"
export const NotFound: React.FC = () => ( export const NotFound: React.FC = () => (
<section className={s.section}> <section className={s.section}>
@@ -10,7 +10,7 @@ export const NotFound: React.FC = () => (
</div> </div>
<div> <div>
<Link href={'/'}> <Link href={"/"}>
<a>На главную</a> <a>На главную</a>
</Link> </Link>
</div> </div>
+1 -1
View File
@@ -1,4 +1,4 @@
import * as React from 'react' import * as React from "react"
export interface ITransitionProps { export interface ITransitionProps {
duration: number duration: number
+6 -6
View File
@@ -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])
+4 -4
View File
@@ -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}
+2 -2
View File
@@ -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
+15 -15
View File
@@ -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}
/> />
)} )}
+9 -9
View File
@@ -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 : (
+5 -5
View File
@@ -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>
)} )}
+15 -15
View File
@@ -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>
@@ -52,4 +52,4 @@ export const Picture: React.FC<PictureProps> = memo(({ wide = false, ...props })
) )
}) })
Picture.displayName = 'Picture' Picture.displayName = "Picture"
+2 -2
View File
@@ -1,10 +1,10 @@
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,
}, },
+3 -3
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
import React from 'react' import React from "react"
function script(account) { function script(account) {
return ` return `
+1 -1
View File
@@ -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
} }
+34 -34
View File
@@ -5,68 +5,68 @@ const config = {
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",
}, },
], ],
} }
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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)
} }
+2 -2
View File
@@ -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 -3
View File
@@ -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,7 +8,7 @@ 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,
}) })
+5 -5
View File
@@ -1,9 +1,9 @@
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 {
@@ -15,7 +15,7 @@ export function ext(mimeType: string): string {
} }
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)
+12 -12
View File
@@ -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,
+3 -3
View File
@@ -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
View File
@@ -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 -3
View File
@@ -1,4 +1,4 @@
import { NextPageContext } from 'next' import { NextPageContext } from "next"
export interface IResponseItems<T> { export interface IResponseItems<T> {
items: T[] items: T[]
@@ -14,8 +14,8 @@ export interface IResponseItems<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)
+20 -20
View File
@@ -1,7 +1,7 @@
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,7 +19,7 @@ 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,
}, },
@@ -27,39 +27,39 @@ export function createEmbed(component: StrapiComponentEmbed): Token {
} }
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,
@@ -70,17 +70,17 @@ export async function createPageToken(component: StrapiComponent): Promise<Token
} }
} }
case 'hudozka.embed': { case "hudozka.embed": {
return createEmbed(component) return createEmbed(component)
} }
case 'hudozka.card-grid': { case "hudozka.card-grid": {
const items = await Promise.all(component.items const items = await Promise.all(component.items
.filter(Boolean) .filter(Boolean)
.map(createCardGrid) .map(createCardGrid)
) )
return { return {
token: 'grid', token: "grid",
data: { data: {
items, items,
}, },
@@ -89,7 +89,7 @@ export async function createPageToken(component: StrapiComponent): Promise<Token
default: default:
return { return {
token: 'text', token: "text",
data: ` ${JSON.stringify(component)}`, 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: '',
+2 -2
View File
@@ -22,9 +22,9 @@ export async function encodeImageToBlurhash(url: string) {
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 } = await t.toBuffer({ resolveWithObject: true }) const { data } = await t.toBuffer({ resolveWithObject: true })
return `data:image/jpeg;base64,${data.toString('base64')}` return `data:image/jpeg;base64,${data.toString("base64")}`
} }
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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[]
} }