From f993b4e5b54f29689bdcb34baa09178b08541484 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Thu, 27 Feb 2020 11:24:19 +0300 Subject: [PATCH] drop album support from app --- pages/album/[slug].tsx | 78 -------------- pages/gallery.tsx | 115 --------------------- scripts/sitemap.js | 10 -- src/config.ts | 4 - src/style/components/album-collection.scss | 16 --- src/style/components/gallery-item.scss | 17 --- src/style/style.scss | 2 - 7 files changed, 242 deletions(-) delete mode 100644 pages/album/[slug].tsx delete mode 100644 pages/gallery.tsx delete mode 100644 src/style/components/album-collection.scss delete mode 100644 src/style/components/gallery-item.scss diff --git a/pages/album/[slug].tsx b/pages/album/[slug].tsx deleted file mode 100644 index 0ee6e3d6..00000000 --- a/pages/album/[slug].tsx +++ /dev/null @@ -1,78 +0,0 @@ -import Head from 'next/head' -import { App } from 'src/components/App' -import { Article } from 'src/components/Article' -import { Html } from 'src/components/Html' -import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib' -import { NextPage } from 'next' - -type Props = { - data: any //(album) -} - -const Page: NextPage = props => { - if (!props?.data) { - console.log('kek error', props) - - return null - } - - return ( - - - {props.data.title} - - -
- -
-
- ) -} - -export const unstable_getStaticProps = async (ctx: any) => { - // const id = ctx.query.slug - const id = ctx.params.slug - const data = await requestGet(createApiUrl(`/api/albums/${id}`), null) - - if (!data) { - throw new Error(`kek ${id}`) - } - - return { - props: { - data, - } - } -} - -export const unstable_getStaticPaths = async () => { - console.log('call album unstable_getStaticPaths') - - const urls = await requestGet>(createApiUrl(`/api/albums/urls`), null) - if (!urls) { - return null - } - - return { - paths: urls.items - .map(x => x.replace('/album/', '')) - .map(slug => { - return { - params: { - slug, - }, - } - }), - } -} - -export default Page diff --git a/pages/gallery.tsx b/pages/gallery.tsx deleted file mode 100644 index df7ac59c..00000000 --- a/pages/gallery.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import Head from 'next/head' -import { App } from 'src/components/App' -import { Meta } from 'src/components/Meta' -import { splitBy } from 'src/lib/array' -import { meta } from 'src/lib/meta' -import { createApiUrl, requestGet } from 'src/next-lib' -import { NextPage } from 'next' -import { PageHeader } from 'src/components/PageHeader' - -const albumsByYear = splitBy(album => new Date(album.date).getFullYear()) - -function getMeta() { - return { - description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы' - } -} - -function resize(maxWidth, width, height) { - const ratio = maxWidth / width - - return [ - width * ratio, - height * ratio, - ] -} - -const m = 1 -const AlbumImage = ({ data, alt }) => { - const [width, height] = resize(200, data.width, data.height) - return ( - - {alt} `${url} ${density}x`)} - /> - - ) -} - -const GItem = ({ album }) => ( -
- - - -
-) - -const ACollection = ({ title, albums }) => ( -
-
{title}
-
{ - albums.map((album, index) => ( - - )) - }
-
-) - -interface IProps { - meta: any - title: string - collections: any[] -} - -const Page: NextPage = props => ( - - - {props.title} - - - - - - {props.collections.map(([year, albums], index) => ( - - ))} - -) - -export const unstable_getStaticProps = async (ctx: any) => { - // const pageUrl = ctx.req.url - const res = await requestGet(createApiUrl(`/api/albums`), null) - if (!res) { - return null - } - const items = res.items || [] - const albumCollections = albumsByYear(items) - const title = 'Галерея' - - return { - props: { - collections: [...albumCollections.entries()], - title, - meta: meta({ - title, - description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы' - }) - } - } -} - -export default Page diff --git a/scripts/sitemap.js b/scripts/sitemap.js index 2d256a57..23b1d96a 100644 --- a/scripts/sitemap.js +++ b/scripts/sitemap.js @@ -14,7 +14,6 @@ async function getMenuUrls(frequency = 'daily') { '/schedule', '/documents', '/collective', - '/gallery', ] return menu // .filter(i => 'url' in i) @@ -33,14 +32,6 @@ async function getPageUrls(frequency = 'daily') { })) } -async function getAlbumsUrls() { - const res = await api.get('/api/albums/urls') - return res.data.items.map(url => ({ - changefreq: 'monthly', - url, - })) -} - async function getArticleUrls() { const res = await api.get('/api/articles/urls') @@ -54,7 +45,6 @@ async function getArticleUrls() { let urls = await Promise.all([ getMenuUrls(), getPageUrls(), - getAlbumsUrls(), getArticleUrls(), ]) urls = urls.reduce((urls, i) => urls.concat(i)) diff --git a/src/config.ts b/src/config.ts index 7f139be8..1a5271e0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -47,10 +47,6 @@ export default { name: 'Коллектив', href: '/collective', }, - { - name: 'Галерея', - href: '/gallery', - }, { name: '«Мы соседи»', href: '/neighbors', diff --git a/src/style/components/album-collection.scss b/src/style/components/album-collection.scss deleted file mode 100644 index 054078ef..00000000 --- a/src/style/components/album-collection.scss +++ /dev/null @@ -1,16 +0,0 @@ -.album-collection{ - &__body{ - display: flex; - flex-wrap: wrap; - position: relative; - justify-content: flex-start; - align-items:center; - - margin: 0 0 var(--double-margin); - } - - &__title{ - text-align: center; - margin: var(--single-margin )0; - } -} diff --git a/src/style/components/gallery-item.scss b/src/style/components/gallery-item.scss deleted file mode 100644 index 4955cf4d..00000000 --- a/src/style/components/gallery-item.scss +++ /dev/null @@ -1,17 +0,0 @@ -.gallery-item { - box-sizing: padding-box; - padding: 0; - - margin: 0 var(--single-margin) var(--double-margin); - - a.invisible { - border-bottom: none; - text-decoration: none; - } -} - -@media screen and (max-width: var(--mobile-width)) { - .gallery-item { - margin: 0 0 var(--double-margin); - } -} diff --git a/src/style/style.scss b/src/style/style.scss index 0ce755ac..2ca1d83c 100644 --- a/src/style/style.scss +++ b/src/style/style.scss @@ -1,5 +1,3 @@ -@import "components/album-collection"; -@import "components/gallery-item"; @import "components/document"; @import "components/document-row"; @import "components/documents-container";