initial static export in teachers
This commit is contained in:
1 parent
92460592b4
commit
997e44483e
5 files changed
+134
-89
No files matched your search
+21
-21
@@ -160,27 +160,27 @@ module.exports = withCss(withSass({
|
|||||||
'/info/navigator',
|
'/info/navigator',
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
...createPath(
|
// ...createPath(
|
||||||
'/teacher/[person]',
|
// '/teacher/[person]',
|
||||||
x => x.replace('/teacher/', ''),
|
// x => x.replace('/teacher/', ''),
|
||||||
person => ({ person }),
|
// person => ({ person }),
|
||||||
[
|
// [
|
||||||
'/teacher/as-timasheva',
|
// '/teacher/as-timasheva',
|
||||||
'/teacher/va-sarzhin',
|
// '/teacher/va-sarzhin',
|
||||||
'/teacher/vv-voronova',
|
// '/teacher/vv-voronova',
|
||||||
'/teacher/ea-burovtseva',
|
// '/teacher/ea-burovtseva',
|
||||||
'/teacher/ey-tarasova',
|
// '/teacher/ey-tarasova',
|
||||||
'/teacher/iv-khramov',
|
// '/teacher/iv-khramov',
|
||||||
'/teacher/in-vturina',
|
// '/teacher/in-vturina',
|
||||||
'/teacher/ma-khramova',
|
// '/teacher/ma-khramova',
|
||||||
'/teacher/mg-timasheva',
|
// '/teacher/mg-timasheva',
|
||||||
'/teacher/my-valkova',
|
// '/teacher/my-valkova',
|
||||||
'/teacher/nv-andreeva',
|
// '/teacher/nv-andreeva',
|
||||||
'/teacher/od-gogoleva',
|
// '/teacher/od-gogoleva',
|
||||||
'/teacher/rk-timashev',
|
// '/teacher/rk-timashev',
|
||||||
'/teacher/sa-latipova',
|
// '/teacher/sa-latipova',
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
...createPath(
|
...createPath(
|
||||||
'/article/[article]',
|
'/article/[article]',
|
||||||
x => x.replace('/article/', ''),
|
x => x.replace('/article/', ''),
|
||||||
|
|||||||
Generated
+17
-17
@@ -1059,9 +1059,9 @@
|
|||||||
"integrity": "sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw=="
|
"integrity": "sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw=="
|
||||||
},
|
},
|
||||||
"@next/polyfill-nomodule": {
|
"@next/polyfill-nomodule": {
|
||||||
"version": "9.2.2-canary.16",
|
"version": "9.2.2-canary.18",
|
||||||
"resolved": "https://registry.npmjs.org/@next/polyfill-nomodule/-/polyfill-nomodule-9.2.2-canary.16.tgz",
|
"resolved": "https://registry.npmjs.org/@next/polyfill-nomodule/-/polyfill-nomodule-9.2.2-canary.18.tgz",
|
||||||
"integrity": "sha512-VPAaxYJ9cDaaC+imgOTCNJmB4zijXaArF+Nv7KZS7zO5KpltFFNZSmsDO1Mw8jkJbZ4qWDmqpK/d+ZJoqwzOVQ=="
|
"integrity": "sha512-YryD2l6Vzfjd8dHBu4GA0VJI/mBB0U6tmoOI8bum/C22S1Oh3OzWpBTkMVGXyxTVsOZM6jArVNSaL69Ps67vlA=="
|
||||||
},
|
},
|
||||||
"@types/accepts": {
|
"@types/accepts": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@@ -1987,7 +1987,7 @@
|
|||||||
},
|
},
|
||||||
"babel-plugin-syntax-jsx": {
|
"babel-plugin-syntax-jsx": {
|
||||||
"version": "6.18.0",
|
"version": "6.18.0",
|
||||||
"resolved": "http://storage.mds.yandex.net/get-npm/66641/babel-plugin-syntax-jsx-6.18.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz",
|
||||||
"integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY="
|
"integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY="
|
||||||
},
|
},
|
||||||
"babel-plugin-transform-define": {
|
"babel-plugin-transform-define": {
|
||||||
@@ -2439,9 +2439,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"make-dir": {
|
"make-dir": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.2.tgz",
|
||||||
"integrity": "sha512-NFCymdWS4z/T+3AQ6tjsknt/+4hikbOe6zdq9ZBoPFfoX1S3fthRUbQWzZhI4WZBOM0kQ0GkhdCdfdan3HK+wg==",
|
"integrity": "sha512-rYKABKutXa6vXTXhoV18cBE7PaewPXHe/Bdq4v+ZLMhxbWApkFFplT0LcbMW+6BbjnQXzZ/sAvSE/JdguApG5w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"semver": "^6.0.0"
|
"semver": "^6.0.0"
|
||||||
}
|
}
|
||||||
@@ -2836,9 +2836,9 @@
|
|||||||
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
|
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
|
||||||
},
|
},
|
||||||
"make-dir": {
|
"make-dir": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.2.tgz",
|
||||||
"integrity": "sha512-NFCymdWS4z/T+3AQ6tjsknt/+4hikbOe6zdq9ZBoPFfoX1S3fthRUbQWzZhI4WZBOM0kQ0GkhdCdfdan3HK+wg==",
|
"integrity": "sha512-rYKABKutXa6vXTXhoV18cBE7PaewPXHe/Bdq4v+ZLMhxbWApkFFplT0LcbMW+6BbjnQXzZ/sAvSE/JdguApG5w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"semver": "^6.0.0"
|
"semver": "^6.0.0"
|
||||||
}
|
}
|
||||||
@@ -5280,7 +5280,7 @@
|
|||||||
},
|
},
|
||||||
"is-plain-obj": {
|
"is-plain-obj": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "http://storage.mds.yandex.net/get-npm/69187/is-plain-obj-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
|
||||||
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
|
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4="
|
||||||
},
|
},
|
||||||
"is-plain-object": {
|
"is-plain-object": {
|
||||||
@@ -6691,9 +6691,9 @@
|
|||||||
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw=="
|
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw=="
|
||||||
},
|
},
|
||||||
"next": {
|
"next": {
|
||||||
"version": "9.2.2-canary.16",
|
"version": "9.2.2-canary.18",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-9.2.2-canary.16.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-9.2.2-canary.18.tgz",
|
||||||
"integrity": "sha512-k4SuXSc6LxnfD7oehFxVxhJuXonzPg9ERlRarqUaUbuWOy6y8mXwJVYd36DNiXJlgXGjsRReSsVNC8d7fIlenQ==",
|
"integrity": "sha512-OiIaIJtmwBQG3C6Te6VIHbvKrlrVQiIaPaxevjsRv9pmdghcWmzuaCQoXx/SC6rwdvDAXKS8BtDczXJsx6mREQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ampproject/toolbox-optimizer": "1.1.1",
|
"@ampproject/toolbox-optimizer": "1.1.1",
|
||||||
"@babel/core": "7.7.2",
|
"@babel/core": "7.7.2",
|
||||||
@@ -6711,7 +6711,7 @@
|
|||||||
"@babel/preset-typescript": "7.7.2",
|
"@babel/preset-typescript": "7.7.2",
|
||||||
"@babel/runtime": "7.7.2",
|
"@babel/runtime": "7.7.2",
|
||||||
"@babel/runtime-corejs2": "7.7.2",
|
"@babel/runtime-corejs2": "7.7.2",
|
||||||
"@next/polyfill-nomodule": "9.2.2-canary.16",
|
"@next/polyfill-nomodule": "9.2.2-canary.18",
|
||||||
"amphtml-validator": "1.0.23",
|
"amphtml-validator": "1.0.23",
|
||||||
"async-retry": "1.2.3",
|
"async-retry": "1.2.3",
|
||||||
"async-sema": "3.0.0",
|
"async-sema": "3.0.0",
|
||||||
@@ -7325,7 +7325,7 @@
|
|||||||
},
|
},
|
||||||
"normalize-range": {
|
"normalize-range": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
"resolved": "http://storage.mds.yandex.net/get-npm/38095/normalize-range-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz",
|
||||||
"integrity": "sha1-LRDAa9/TEuqXd2laTShDlFa3WUI="
|
"integrity": "sha1-LRDAa9/TEuqXd2laTShDlFa3WUI="
|
||||||
},
|
},
|
||||||
"normalize-url": {
|
"normalize-url": {
|
||||||
@@ -7353,7 +7353,7 @@
|
|||||||
},
|
},
|
||||||
"num2fraction": {
|
"num2fraction": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "http://storage.mds.yandex.net/get-npm/38095/num2fraction-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz",
|
||||||
"integrity": "sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4="
|
"integrity": "sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4="
|
||||||
},
|
},
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"mongodb": "^2.1.14",
|
"mongodb": "^2.1.14",
|
||||||
"next": "^9.2.2-canary.16",
|
"next": "^9.2.2-canary.18",
|
||||||
"react": "^16.12.0",
|
"react": "^16.12.0",
|
||||||
"react-dom": "^16.12.0",
|
"react-dom": "^16.12.0",
|
||||||
"sitemap": "^1.5.0",
|
"sitemap": "^1.5.0",
|
||||||
|
|||||||
+14
-12
@@ -9,8 +9,8 @@ import menuModel from 'src/models/menu'
|
|||||||
import { buildMenu } from 'src/lib/menu'
|
import { buildMenu } from 'src/lib/menu'
|
||||||
import { meta } from 'src/lib/meta'
|
import { meta } from 'src/lib/meta'
|
||||||
import { IMeta } from 'src/types'
|
import { IMeta } from 'src/types'
|
||||||
import { createApiUrl, requestGet, wrapInitialProps, IResponseItems } from 'src/next-lib'
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
import { NextPage } from 'next'
|
import { NextPage, NextPageContext } from 'next'
|
||||||
|
|
||||||
interface IPerson {
|
interface IPerson {
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ const Page: NextPage<Props> = props => (
|
|||||||
</App>
|
</App>
|
||||||
)
|
)
|
||||||
|
|
||||||
Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
export const unstable_getServerProps = async (ctx: NextPageContext) => {
|
||||||
const pageUrl = ctx.req.url
|
const pageUrl = ctx.req.url
|
||||||
|
|
||||||
const res = await requestGet<IResponseItems<IPerson>>(createApiUrl(ctx.req, '/api/persons'), { items: [] })
|
const res = await requestGet<IResponseItems<IPerson>>(createApiUrl(ctx.req, '/api/persons'), { items: [] })
|
||||||
@@ -71,16 +71,18 @@ Page.getInitialProps = wrapInitialProps(async (ctx) => {
|
|||||||
const image = get(resImage, 'artifacts.large', null)
|
const image = get(resImage, 'artifacts.large', null)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
persons,
|
props: {
|
||||||
image,
|
persons,
|
||||||
pageUrl,
|
image,
|
||||||
title,
|
pageUrl,
|
||||||
meta: meta({
|
|
||||||
title,
|
title,
|
||||||
url: pageUrl,
|
meta: meta({
|
||||||
description: 'Преподаватели Шлиссельбургской ДХШ',
|
title,
|
||||||
})
|
url: pageUrl,
|
||||||
|
description: 'Преподаватели Шлиссельбургской ДХШ',
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
export default Page
|
export default Page
|
||||||
+81
-38
@@ -5,8 +5,8 @@ import { Meta } from 'src/components/Meta'
|
|||||||
import menuModel from 'src/models/menu'
|
import menuModel from 'src/models/menu'
|
||||||
import { buildMenu } from 'src/lib/menu'
|
import { buildMenu } from 'src/lib/menu'
|
||||||
import { meta } from 'src/lib/meta'
|
import { meta } from 'src/lib/meta'
|
||||||
import { createApiUrl, requestGet, wrapInitialProps } from 'src/next-lib'
|
import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
||||||
import { NextPage } from 'next'
|
import { NextPage, NextPageContext } from 'next'
|
||||||
import { IMeta } from 'src/types'
|
import { IMeta } from 'src/types'
|
||||||
import Html from 'src/components/Html'
|
import Html from 'src/components/Html'
|
||||||
|
|
||||||
@@ -17,50 +17,93 @@ interface IProps {
|
|||||||
person: any
|
person: any
|
||||||
}
|
}
|
||||||
|
|
||||||
const Index: NextPage<IProps> = props => (
|
const Index: NextPage<IProps> = props => {
|
||||||
<App
|
if (!props?.person?.post) {
|
||||||
menu={buildMenu(props.pageUrl, menuModel)}
|
console.log('kek error', props)
|
||||||
showAuthor={true}
|
|
||||||
menuPadding={true}
|
|
||||||
layout={'thin'}
|
|
||||||
>
|
|
||||||
<Head>
|
|
||||||
<title>{props.title}</title>
|
|
||||||
<Meta meta={props.meta} />
|
|
||||||
</Head>
|
|
||||||
|
|
||||||
<Article
|
return null
|
||||||
title={''}
|
}
|
||||||
tags={[]}
|
|
||||||
date={null}
|
return (
|
||||||
shareable={true}
|
<App
|
||||||
|
menu={buildMenu(props.pageUrl, menuModel)}
|
||||||
|
showAuthor={true}
|
||||||
|
menuPadding={true}
|
||||||
|
layout={'thin'}
|
||||||
>
|
>
|
||||||
<Html
|
<Head>
|
||||||
html={props.person.post}
|
<title>{props.title}</title>
|
||||||
/>
|
<Meta meta={props.meta} />
|
||||||
</Article>
|
</Head>
|
||||||
</App>
|
|
||||||
)
|
{!props.person.post ? null : (
|
||||||
|
<Article
|
||||||
|
title={''}
|
||||||
|
tags={[]}
|
||||||
|
date={null}
|
||||||
|
shareable={true}
|
||||||
|
>
|
||||||
|
<Html
|
||||||
|
html={props.person.post}
|
||||||
|
/>
|
||||||
|
</Article>
|
||||||
|
)}
|
||||||
|
</App>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticProps = async (ctx: any) => {
|
||||||
|
console.log('call unstable_getStaticProps', ctx)
|
||||||
|
|
||||||
Index.getInitialProps = wrapInitialProps(async (ctx) => {
|
|
||||||
const pageUrl = '/collective'
|
const pageUrl = '/collective'
|
||||||
const id = ctx.query.person
|
// const id = ctx.query.person
|
||||||
const person: any = await requestGet(createApiUrl(ctx.req, `/api/persons/${id}`), {})
|
// const id = ctx.params.person ?? 'va-sarzhin'
|
||||||
|
const id = ctx.params.person //?? 'mg-timasheva'
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
throw new Error('sry')
|
||||||
|
}
|
||||||
|
|
||||||
|
// const person: any = await requestGet(createApiUrl(ctx.req, `/api/persons/${id}`), {})
|
||||||
|
const person: any = await requestGet(`http://localhost:3000/api/persons/${id}`, {})
|
||||||
const name = person.name || []
|
const name = person.name || []
|
||||||
const title = name.join(' ')
|
const title = name.join(' ')
|
||||||
const image = person.preview ? person.preview.artifacts.fb : {}
|
const image = person.preview ? person.preview.artifacts.fb : {}
|
||||||
|
|
||||||
return {
|
if (!person?.post) {
|
||||||
pageUrl,
|
throw new Error(`post kek ${id}`)
|
||||||
person,
|
|
||||||
title,
|
|
||||||
meta: meta({
|
|
||||||
title,
|
|
||||||
image: image.src,
|
|
||||||
imageWidth: image.width,
|
|
||||||
imageHeight: image.height,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
pageUrl,
|
||||||
|
person,
|
||||||
|
title,
|
||||||
|
meta: meta({
|
||||||
|
title,
|
||||||
|
image: image.src,
|
||||||
|
imageWidth: image.width,
|
||||||
|
imageHeight: image.height,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const unstable_getStaticPaths = async () => {
|
||||||
|
console.log('call unstable_getStaticPaths')
|
||||||
|
|
||||||
|
const urls = await requestGet<IResponseItems<string>>(`http://localhost:3000/api/persons/urls`, null)
|
||||||
|
// const urls = {items: ['/teacher/va-sarzhin']}
|
||||||
|
|
||||||
|
return {
|
||||||
|
paths: urls.items
|
||||||
|
.map(x => x.replace('/teacher/', ''))
|
||||||
|
.map(person => ({
|
||||||
|
params: {
|
||||||
|
person,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default Index
|
export default Index
|
||||||
Reference in new issue
Block a user