app moved to next.js
This commit is contained in:
1 parent
dcca513aea
commit
43af2996bf
48 files changed
+1147
-1027
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import React from 'react'
|
||||
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
// static async getInitialProps(ctx) {
|
||||
// const initialProps = await Document.getInitialProps(ctx);
|
||||
// return { ...initialProps };
|
||||
// }
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<style>{`body { margin: 0 } /* custom! */`}</style>
|
||||
|
||||
<script src='/static/likely.js'></script>
|
||||
<link href='/static/likely.css' rel='stylesheet' />
|
||||
</Head>
|
||||
|
||||
<body className="custom_class">
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../../src/components/App'
|
||||
import Article from '../../src/components/Article'
|
||||
import Html from '../../src/components/Html'
|
||||
import menuModel from '../../src/models/menu'
|
||||
import { buildMenu } from '../../src/lib/menu'
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_thin">
|
||||
<Article
|
||||
title={props.album.title}
|
||||
date={props.album.date}
|
||||
shareable={true}
|
||||
>
|
||||
<Html
|
||||
html={props.album.post}
|
||||
/>
|
||||
</Article>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const id = ctx.query.album
|
||||
const apiUrl = `http://localhost:3000/api/albums/${id}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const album = res.data
|
||||
|
||||
return {
|
||||
album,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,19 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Album from '../../../src/core/Album'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const id = req.query.album
|
||||
const album = await Album.findById(id)
|
||||
|
||||
if (album) {
|
||||
res.json(album)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Album ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Album from '../../../src/core/Album'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const data = await Album.find({}, { sort: { date: -1 } })
|
||||
if (data) {
|
||||
res.json({
|
||||
items: data,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Article from '../../../src/core/Article'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const {
|
||||
query: { article: id }
|
||||
} = req;
|
||||
|
||||
const article = await Article.findById(id)
|
||||
|
||||
if (article) {
|
||||
res.json(article)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import { findArticles } from '../../../src/api/articles'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const { query } = req
|
||||
const page = parseInt(query.page)
|
||||
const pageSize = parseInt(query.pageSize)
|
||||
|
||||
const data = await findArticles(page, pageSize)
|
||||
|
||||
if (data) {
|
||||
res.json(data)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Document from '../../../src/core/Document'
|
||||
import { encodeFile } from '../../../src/api/files'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const id = req.query.document
|
||||
const document = await Document.findById(id)
|
||||
|
||||
if (document) {
|
||||
res.json(encodeFile(document))
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Document ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Document from '../../../src/core/Document'
|
||||
import { encodeFile } from '../../../src/api/files'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const documents = await Document.find({hidden: false})
|
||||
if (documents) {
|
||||
const items = documents
|
||||
.map(encodeFile)
|
||||
.filter(x => x.imageUrl) // skip documents without preview image; needs to be refactored
|
||||
|
||||
res.json({
|
||||
items,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Documents not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { dbUri } from '../../src/config'
|
||||
import { connect } from '../../src/core/db'
|
||||
import Image from '../../src/core/Image'
|
||||
import ImageArtifactType from '../../src/core/ImageArtifactType'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const file = req.query.file
|
||||
const image = await Image.findByFile(file)
|
||||
|
||||
if (image) {
|
||||
const data = image.getPicture(ImageArtifactType.LARGE)
|
||||
res.json(data)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Image ${file} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { dbUri } from '../../src/config'
|
||||
import { connect } from '../../src/core/db'
|
||||
import Page from '../../src/core/Page'
|
||||
import { getPathWithNoTrailingSlash } from '../../src/lib/url'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const page = getPathWithNoTrailingSlash(req.query.page)
|
||||
const resource = await Page.findByUrl(page)
|
||||
|
||||
if (resource) {
|
||||
res.json({
|
||||
id: resource.id,
|
||||
title: resource.title,
|
||||
url: resource.url,
|
||||
data: resource.data,
|
||||
preview: resource.preview,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Image ${page} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Teacher from '../../../src/core/Teacher'
|
||||
import { encodePerson } from '../../../src/api/persons'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const id = req.query.person
|
||||
const person = await Teacher.findById(id)
|
||||
const data = encodePerson(person)
|
||||
|
||||
if (data) {
|
||||
res.json(data)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Teacher from '../../../src/core/Teacher'
|
||||
import { prioritySort } from '../../../src/lib/sort'
|
||||
import { encodePerson } from '../../../src/api/persons'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const order = [
|
||||
'mg-timasheva',
|
||||
'va-sarzhin',
|
||||
'od-gogoleva',
|
||||
'my-valkova',
|
||||
'nv-andreeva',
|
||||
'vv-voronova',
|
||||
]
|
||||
const teachersSorted = prioritySort.bind(null, [...order], t => t.id)
|
||||
|
||||
const teachers = await Teacher.find({ hidden: false })
|
||||
const data = teachersSorted(teachers).map(encodePerson)
|
||||
|
||||
if (data) {
|
||||
res.json({
|
||||
items: data,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { dbUri } from '../../src/config'
|
||||
import { connect } from '../../src/core/db'
|
||||
import { findSchedule } from '../../src/core/schedule'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const period = req.query.period
|
||||
const semester = req.query.semester
|
||||
const data = await findSchedule(period, semester)
|
||||
|
||||
if (data) {
|
||||
res.json(data)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Schedule ${period}:${semester} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../../src/components/App'
|
||||
import Article from '../../src/components/Article'
|
||||
import Html from '../../src/components/Html'
|
||||
import menuModel from '../../src/models/menu'
|
||||
import { buildMenu } from '../../src/lib/menu'
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className={'content content_thin'}>
|
||||
<Article
|
||||
title={props.article.title}
|
||||
date={props.article.date}
|
||||
tags={props.article.tags}
|
||||
shareable={true}
|
||||
>
|
||||
<Html
|
||||
html={props.article.post}
|
||||
/>
|
||||
</Article>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const id = ctx.query.article
|
||||
const apiUrl = `http://localhost:3000/api/articles/${id}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const article = res.data
|
||||
|
||||
return {
|
||||
article,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,52 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../../src/components/App'
|
||||
import ArticleCardList from '../../src/components/ArticleCardList'
|
||||
import menuModel from '../../src/models/menu'
|
||||
import { buildMenu } from '../../src/lib/menu'
|
||||
|
||||
function getMeta(article) {
|
||||
return {
|
||||
title: article.title,
|
||||
}
|
||||
}
|
||||
|
||||
// async function renderHome(path, pageSize) {
|
||||
// return render(path, Component, getMeta({ title: 'Шлиссельбургская ДХШ' }), { showAuthor: true })
|
||||
// }
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_wide">
|
||||
<ArticleCardList
|
||||
articles={props.articles}
|
||||
prevPage={props.prevPage}
|
||||
nextPage={props.nextPage}
|
||||
/>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const page = parseInt(ctx.query.page)
|
||||
const pageSize = 10
|
||||
const apiUrl = `http://localhost:3000/api/articles?page=${page}&pageSize=${pageSize}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const articles = res.data.items
|
||||
const nextPage = res.data.nextPage
|
||||
const prevPage = res.data.prevPage
|
||||
|
||||
return {
|
||||
articles,
|
||||
nextPage,
|
||||
prevPage,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,64 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../src/components/App'
|
||||
import CollectiveImage from '../src/components/CollectiveImage'
|
||||
import PersonCard from '../src/components/PersonCard'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
|
||||
function getMeta(article) {
|
||||
return {
|
||||
title: article.title,
|
||||
}
|
||||
}
|
||||
|
||||
const PersonCardList = ({ children }) => (
|
||||
<div className="PersonCardList">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_semi-wide">
|
||||
{!props.image ? null : (
|
||||
<CollectiveImage data={props.image} />
|
||||
)}
|
||||
|
||||
<PersonCardList>
|
||||
{props.persons.map((person, index) => (
|
||||
<PersonCard
|
||||
key={index}
|
||||
profile={person}
|
||||
picture={person.picture}
|
||||
url={person.url}
|
||||
name={person.name}
|
||||
/>
|
||||
))}
|
||||
</PersonCardList>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const apiUrl = `http://localhost:3000/api/persons`
|
||||
const res = await axios.get(apiUrl)
|
||||
const persons = res.data.items
|
||||
|
||||
const imageFile = 'Images/HudozkaCollective2017.jpg'
|
||||
const imageUrl = `http://localhost:3000/api/image?file=${imageFile}`
|
||||
const resImage = await axios.get(imageUrl)
|
||||
|
||||
return {
|
||||
persons,
|
||||
image: resImage.data,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,35 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../../src/components/App'
|
||||
import Document from '../../src/components/Document'
|
||||
import Share from '../../src/components/Share'
|
||||
import menuModel from '../../src/models/menu'
|
||||
import { buildMenu } from '../../src/lib/menu'
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_wide">
|
||||
<Document {...props.file} />
|
||||
<Share />
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const id = ctx.query.document
|
||||
const apiUrl = `http://localhost:3000/api/files/${id}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const file = res.data
|
||||
|
||||
return {
|
||||
file,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,135 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../src/components/App'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
|
||||
import DocumentList from '../src/components/DocumentList'
|
||||
import ImageArtifactType from '../src/core/ImageArtifactType'
|
||||
import { prioritySort } from '../src/lib/sort'
|
||||
import { splitBy } from '../src/lib/array'
|
||||
import { unique } from '../src/utils/common'
|
||||
|
||||
function getDocumentsMeta() {
|
||||
return {
|
||||
title: 'Документы',
|
||||
description: 'Документы Шлиссельбургской ДХШ',
|
||||
}
|
||||
}
|
||||
|
||||
function getMeta(teacher) {
|
||||
return {
|
||||
title: teacher.name,
|
||||
description: teacher.name,
|
||||
}
|
||||
}
|
||||
|
||||
function getSorted(documents) {
|
||||
const compose = (...fns) => value => fns
|
||||
.map(fn => fn)
|
||||
.reverse()
|
||||
.reduce((acc, fn) => fn(acc), value)
|
||||
|
||||
const pass = fn => value => {
|
||||
fn(value)
|
||||
return value
|
||||
}
|
||||
|
||||
const subtract = (a, b) => a - b
|
||||
|
||||
const uniqueCategories = unique(i => i.category)
|
||||
|
||||
const priority = {
|
||||
'Основные документы': [
|
||||
'https://static.shlisselburg.org/art/uploads/ustav-2015.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/obrazovatelnaia-litsenziia-2015.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/svidetelstvo-na-pomeshchenie.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/egriul.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/inn.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/reshenie-o-sozdanii-shkoly.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/kopiia-resheniia-o-naznachenii-rukovoditelia.pdf',
|
||||
'https://static.shlisselburg.org/art/uploads/postanovlenie-o-sozdanii-munitsipalnogo-obrazovatelnogo-uchrezhdeniia-kultury-detskaia-khudozhestvennaia-shkola.pdf',
|
||||
],
|
||||
'Учебные программы': [
|
||||
'https://static.shlisselburg.org/art/uploads/uchebnaia-programma-zhivopis.pdf',
|
||||
]
|
||||
}
|
||||
|
||||
const CATEGORY_PRIORITY = [
|
||||
'Основные документы',
|
||||
'Планы ФХД',
|
||||
'Самообследование деятельности',
|
||||
'Инструкции',
|
||||
'Образование',
|
||||
'Учебные программы',
|
||||
'Платные образовательные услуги',
|
||||
'Дополнительные общеразвивающие программы',
|
||||
'Документы для поступления',
|
||||
]
|
||||
|
||||
const sortBy = fn => (a, b) => [a, b]
|
||||
.map(fn)
|
||||
.reduce(subtract)
|
||||
|
||||
const getPriorityFn = (m, list) => value => list.includes(value)
|
||||
? list.indexOf(value)
|
||||
: m
|
||||
|
||||
const safeSelect = (d, store, key) => key in store
|
||||
? store[key]
|
||||
: d
|
||||
|
||||
const categoryPriority = getPriorityFn(10000, CATEGORY_PRIORITY)
|
||||
|
||||
const documentPriority = ({ category, fileUrl }) => compose(
|
||||
getPriorityFn.bind(null, 10000),
|
||||
safeSelect.bind(null, [], priority)
|
||||
)(category)(fileUrl)
|
||||
|
||||
const documentsOf = category => documents.filter(i => i.category === category)
|
||||
const sorted = documents => documents.sort(sortBy(documentPriority))
|
||||
const collectDocumentsByCategory = compose(sorted, documentsOf)
|
||||
|
||||
return uniqueCategories(documents)
|
||||
.sort(sortBy(categoryPriority))
|
||||
.reduce((acc, name) => [...acc, {
|
||||
name,
|
||||
items: collectDocumentsByCategory(name)
|
||||
}], [])
|
||||
}
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_thin">
|
||||
{/* <pre>{JSON.stringify(props, null, 4)}</pre> */}
|
||||
|
||||
{props.collections.map(({ name, items }, index) => (
|
||||
<DocumentList
|
||||
key={index}
|
||||
name={name}
|
||||
documents={items}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const apiUrl = `http://localhost:3000/api/files`
|
||||
const res = await axios.get(apiUrl)
|
||||
const files = res.data.items
|
||||
|
||||
const collections = getSorted(files)
|
||||
|
||||
return {
|
||||
collections,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,90 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../src/components/App'
|
||||
// import Album from '../src/components/Album'
|
||||
import Article from '../src/components/Article'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
import { splitBy } from '../src/lib/array'
|
||||
|
||||
const albumsByYear = splitBy(album => new Date(album.date).getFullYear())
|
||||
|
||||
function getMeta() {
|
||||
return {
|
||||
title: 'Галерея',
|
||||
description: 'Галерея работ учащихся Шлиссельбургской Детской Художественной Школы'
|
||||
}
|
||||
}
|
||||
|
||||
const m = 1
|
||||
const AlbumImage = ({ data, alt }) => (
|
||||
<picture>
|
||||
<img
|
||||
className="opa"
|
||||
alt={alt}
|
||||
src={data.src}
|
||||
width={data.width * m}
|
||||
height={data.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>
|
||||
)
|
||||
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_semi-wide">
|
||||
<Article
|
||||
// title={meta.title}
|
||||
title={'Галерея'}
|
||||
>
|
||||
{props.collections.map(([year, albums], index) => (
|
||||
<ACollection
|
||||
key={index}
|
||||
title={year}
|
||||
albums={albums}
|
||||
/>
|
||||
))
|
||||
}
|
||||
</Article>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const apiUrl = `http://localhost:3000/api/albums`
|
||||
const res = await axios.get(apiUrl)
|
||||
const items = res.data.items
|
||||
const albumCollections = albumsByYear(items)
|
||||
|
||||
return {
|
||||
collections: [...albumCollections.entries()],
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,55 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../src/components/App'
|
||||
import ArticleCardList from '../src/components/ArticleCardList'
|
||||
import HudozkaTitle from '../src/components/HudozkaTitle'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
|
||||
function getMeta(article) {
|
||||
return {
|
||||
title: article.title,
|
||||
}
|
||||
}
|
||||
|
||||
// async function renderHome(path, pageSize) {
|
||||
// return render(path, Component, getMeta({ title: 'Шлиссельбургская ДХШ' }), { showAuthor: true })
|
||||
// }
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_wide">
|
||||
<HudozkaTitle />
|
||||
|
||||
<ArticleCardList
|
||||
articles={props.articles}
|
||||
prevPage={props.prevPage}
|
||||
nextPage={props.nextPage}
|
||||
/>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const page = 1
|
||||
const pageSize = 10
|
||||
const apiUrl = `http://localhost:3000/api/articles?page=${page}&pageSize=${pageSize}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const articles = res.data.items
|
||||
const nextPage = res.data.nextPage
|
||||
const prevPage = res.data.prevPage
|
||||
|
||||
return {
|
||||
articles,
|
||||
nextPage,
|
||||
prevPage,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../src/components/App'
|
||||
import Page from '../src/components/Page'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
|
||||
const Index = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
{/* <pre>{JSON.stringify(props, null, 4)}</pre> */}
|
||||
<div className={'content content_thin'}>
|
||||
<Page
|
||||
shareable={true}
|
||||
>
|
||||
{props.content}
|
||||
</Page>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Index.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
// // const pageUrl = '/neighbors/2018'
|
||||
const apiUrl = `http://localhost:3000/api/page?page=${pageUrl}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const page = res.data
|
||||
|
||||
return {
|
||||
content: page.data,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Index
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../src/components/App'
|
||||
import Schedule from '../src/components/Schedule'
|
||||
import Share from '../src/components/Share'
|
||||
import menuModel from '../src/models/menu'
|
||||
import { buildMenu } from '../src/lib/menu'
|
||||
|
||||
const Page = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_wide">
|
||||
{/*<ScheduleList schedules={schedules}/>*/}
|
||||
|
||||
<Schedule {...props.schedule} />
|
||||
|
||||
<Share />
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Page.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const period = '2016-2017'
|
||||
const semester = 'spring'
|
||||
const apiUrl = `http://localhost:3000/api/schedule?period=${period}&semester=${semester}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const schedule = res.data
|
||||
|
||||
return {
|
||||
schedule,
|
||||
pageUrl,
|
||||
}
|
||||
}
|
||||
|
||||
export default Page
|
||||
@@ -0,0 +1,35 @@
|
||||
import React from 'react'
|
||||
import axios from 'axios'
|
||||
import App from '../../src/components/App'
|
||||
import Page from '../../src/components/Page'
|
||||
import menuModel from '../../src/models/menu'
|
||||
import { buildMenu } from '../../src/lib/menu'
|
||||
|
||||
const Index = (props) => (
|
||||
<App
|
||||
menu={buildMenu(props.pageUrl, menuModel)}
|
||||
showAuthor={true}
|
||||
menuPadding={true}
|
||||
>
|
||||
<div className="content content_thin">
|
||||
<Page shareable={true}>
|
||||
{props.person.post}
|
||||
</Page>
|
||||
</div>
|
||||
</App>
|
||||
)
|
||||
|
||||
Index.getInitialProps = async (ctx) => {
|
||||
const pageUrl = ctx.req.url
|
||||
const id = ctx.query.person
|
||||
const apiUrl = `http://localhost:3000/api/persons/${id}`
|
||||
const res = await axios.get(apiUrl)
|
||||
const person = res.data
|
||||
|
||||
return {
|
||||
pageUrl,
|
||||
person,
|
||||
}
|
||||
}
|
||||
|
||||
export default Index
|
||||
Reference in new issue
Block a user