diff --git a/modules/hudozka-api/src/core/Article.ts b/modules/hudozka-api/src/core/Article.ts index 6b868781..6a248dff 100644 --- a/modules/hudozka-api/src/core/Article.ts +++ b/modules/hudozka-api/src/core/Article.ts @@ -1,6 +1,5 @@ import Data from './Data' import Image from './Image' -import Config from './Config' import { find, findOne, total } from '../lib/store' import { Tag } from './Tag' @@ -101,13 +100,6 @@ const previewFromImage = (imgs = []) => imgs.length ? imgs[0] : null -async function resolveDefaultPreview() { - const config = await Config.findConfig() - if (!config) return null - - return Image.findByFile(config.articleCardDefaultPreview) -} - async function processArticle(article) { let preview = null const previewId = article.preview @@ -116,8 +108,6 @@ async function processArticle(article) { if (previewId) { preview = await Image.findById(previewId) - } else { - preview = await resolveDefaultPreview() } return new Article({ diff --git a/modules/hudozka-api/src/core/Config.ts b/modules/hudozka-api/src/core/Config.ts deleted file mode 100644 index 086d6c23..00000000 --- a/modules/hudozka-api/src/core/Config.ts +++ /dev/null @@ -1,40 +0,0 @@ -import Data from './Data' -import { findOne } from '../lib/store' - -const store = () => Data.getStore('Settings') - -export default class Config { - static async findConfig() { - const config = await Config.findById('settings') - return config || new Config({} as any) - } - - static async findById(id: string) { - const data = await findOne(store(), { id }) - if (!data) return null - - return new Config(data) - } - - public hash: any - public file: any - public server: any - public articlesPerPage: any - public articleCardDefaultPreview: any - public collectiveImage: any - public redirect: any - - constructor({ hash, file, ...data }) { - this.hash = hash - this.file = file - this.server = data.server - this.articlesPerPage = data.articlesPerPage || 5 - this.articleCardDefaultPreview = data.articleCardDefaultPreview - this.collectiveImage = data.collectiveImage - - const redirect = data.redirect || {} - this.redirect = new Map(Object - .entries(redirect) - ) - } -} diff --git a/modules/hudozka-api/src/core/Page.ts b/modules/hudozka-api/src/core/Page.ts index f35e1fa7..90ca78e0 100644 --- a/modules/hudozka-api/src/core/Page.ts +++ b/modules/hudozka-api/src/core/Page.ts @@ -1,7 +1,6 @@ import Data from './Data' import { find as storeFind, findOne, total } from '../lib/store' import Image from './Image' -import Config from './Config' const store = () => Data.getStore('Page') @@ -80,13 +79,6 @@ const previewFromImage = (imgs = []) => imgs.length ? imgs[0] : null -async function resolveDefaultPreview() { - const config = await Config.findConfig() - if (!config) return null - - return Image.findByFile(config.articleCardDefaultPreview) -} - async function processPage(article) { let preview = null const previewId = article.preview @@ -95,8 +87,6 @@ async function processPage(article) { if (previewId) { preview = await Image.findById(previewId) - } else { - preview = await resolveDefaultPreview() } return new Page({