meta lib refactoring: to ts; add meta builder
This commit is contained in:
1 parent
8c57c69583
commit
0fc762c418
2 files changed
+60
-23
No files matched your search
@@ -1,23 +0,0 @@
|
||||
export function meta(props) {
|
||||
const path = props.url || '/'
|
||||
const url = `https://art.shlisselburg.org${path}`
|
||||
|
||||
return {
|
||||
title: 'Шлиссельбургская ДХШ',
|
||||
description: 'Сайт Шлиссельбургской художественной школы',
|
||||
image: 'https://art.shlisselburg.org/entrance.jpg',
|
||||
imageWidth: 1200,
|
||||
imageHeight: 630,
|
||||
|
||||
siteName: 'Шлиссельбургская Детская Художественная Школа',
|
||||
locale: 'ru_RU',
|
||||
type: 'website',
|
||||
domain: 'art.shlisselburg.org',
|
||||
twitterCard: 'summary_large_image',
|
||||
twitterSite: '@',
|
||||
twitterCreator: '@tmshv',
|
||||
|
||||
...props,
|
||||
url,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { IMeta, IImage } from 'src/types'
|
||||
|
||||
export function meta(props: Partial<IMeta>): IMeta {
|
||||
const path = props.url || '/'
|
||||
const url = `https://art.shlisselburg.org${path}`
|
||||
|
||||
return {
|
||||
title: 'Шлиссельбургская ДХШ',
|
||||
description: 'Сайт Шлиссельбургской художественной школы',
|
||||
image: 'https://art.shlisselburg.org/entrance.jpg',
|
||||
imageWidth: 1200,
|
||||
imageHeight: 630,
|
||||
|
||||
siteName: 'Шлиссельбургская Детская Художественная Школа',
|
||||
locale: 'ru_RU',
|
||||
type: 'website',
|
||||
domain: 'art.shlisselburg.org',
|
||||
twitterCard: 'summary_large_image',
|
||||
twitterSite: '@',
|
||||
twitterCreator: '@tmshv',
|
||||
|
||||
...props,
|
||||
url,
|
||||
}
|
||||
}
|
||||
|
||||
export class MetaBuilder {
|
||||
private image: IImage
|
||||
private title: string
|
||||
private description: string
|
||||
private data: Partial<IMeta>
|
||||
|
||||
setData(param: Partial<IMeta>) {
|
||||
this.data = param
|
||||
return this
|
||||
}
|
||||
|
||||
setTitle(param: string) {
|
||||
this.title = param
|
||||
return this
|
||||
}
|
||||
|
||||
setDescription(param: string) {
|
||||
this.description = param
|
||||
return this
|
||||
}
|
||||
|
||||
setImage(param: IImage) {
|
||||
this.image = param
|
||||
return this
|
||||
}
|
||||
|
||||
build() {
|
||||
return meta({
|
||||
...this.data,
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user