drop album support from app
This commit is contained in:
1 parent
a738ef0f6b
commit
f993b4e5b5
7 files changed
-242
No files matched your search
@@ -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> = props => {
|
||||
if (!props?.data) {
|
||||
console.log('kek error', props)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<App
|
||||
showAuthor={true}
|
||||
>
|
||||
<Head>
|
||||
<title>{props.data.title}</title>
|
||||
</Head>
|
||||
|
||||
<Article
|
||||
title={props.data.title}
|
||||
date={props.data.date}
|
||||
shareable={true}
|
||||
tags={[]}
|
||||
>
|
||||
<Html
|
||||
html={props.data.post}
|
||||
/>
|
||||
</Article>
|
||||
</App>
|
||||
)
|
||||
}
|
||||
|
||||
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<IResponseItems<string>>(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
|
||||
@@ -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 (
|
||||
<picture>
|
||||
<img
|
||||
className="opa"
|
||||
alt={alt}
|
||||
src={data.src}
|
||||
width={width * m}
|
||||
height={height * m}
|
||||
srcSet={(data.set || []).map(({ url, density }) => `${url} ${density}x`)}
|
||||
/>
|
||||
</picture>
|
||||
)
|
||||
}
|
||||
|
||||
const GItem = ({ album }) => (
|
||||
<div className="gallery-item">
|
||||
<a className="invisible" href={album.url}>
|
||||
<AlbumImage data={album.preview} alt={album.title} />
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
|
||||
const ACollection = ({ title, albums }) => (
|
||||
<div className="album-collection">
|
||||
<div className="album-collection__title">{title}</div>
|
||||
<div className="album-collection__body">{
|
||||
albums.map((album, index) => (
|
||||
<GItem key={index} album={album} />
|
||||
))
|
||||
}</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
interface IProps {
|
||||
meta: any
|
||||
title: string
|
||||
collections: any[]
|
||||
}
|
||||
|
||||
const Page: NextPage<IProps> = props => (
|
||||
<App
|
||||
showAuthor={true}
|
||||
wide={true}
|
||||
>
|
||||
<Head>
|
||||
<title>{props.title}</title>
|
||||
<Meta meta={props.meta} />
|
||||
</Head>
|
||||
|
||||
<PageHeader
|
||||
title={props.title}
|
||||
/>
|
||||
|
||||
{props.collections.map(([year, albums], index) => (
|
||||
<ACollection
|
||||
key={index}
|
||||
title={year}
|
||||
albums={albums}
|
||||
/>
|
||||
))}
|
||||
</App>
|
||||
)
|
||||
|
||||
export const unstable_getStaticProps = async (ctx: any) => {
|
||||
// const pageUrl = ctx.req.url
|
||||
const res = await requestGet<any>(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
|
||||
@@ -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))
|
||||
|
||||
@@ -47,10 +47,6 @@ export default {
|
||||
name: 'Коллектив',
|
||||
href: '/collective',
|
||||
},
|
||||
{
|
||||
name: 'Галерея',
|
||||
href: '/gallery',
|
||||
},
|
||||
{
|
||||
name: '«Мы соседи»',
|
||||
href: '/neighbors',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
@import "components/album-collection";
|
||||
@import "components/gallery-item";
|
||||
@import "components/document";
|
||||
@import "components/document-row";
|
||||
@import "components/documents-container";
|
||||
|
||||
Reference in new issue
Block a user