initial tags api
This commit is contained in:
1 parent
11d628fd50
commit
ec2609e900
6 files changed
+156
-9
No files matched your search
@@ -2,6 +2,7 @@ import Data from './Data'
|
||||
import Image from './Image'
|
||||
import Config from './Config'
|
||||
import { find, findOne, total } from '../lib/store'
|
||||
import { Tag } from './Tag'
|
||||
|
||||
const store = () => Data.getStore<Article>('Article')
|
||||
|
||||
@@ -44,7 +45,7 @@ export default class Article {
|
||||
public date: any
|
||||
public title: any
|
||||
public until: any
|
||||
public tags: any
|
||||
public tags: Tag[]
|
||||
public content: any
|
||||
public hash: any
|
||||
public type: any
|
||||
@@ -96,14 +97,6 @@ export default class Article {
|
||||
}
|
||||
}
|
||||
|
||||
class Tag {
|
||||
public name: string
|
||||
|
||||
constructor(tag) {
|
||||
this.name = tag;
|
||||
}
|
||||
}
|
||||
|
||||
const previewFromImage = (imgs = []) => imgs.length
|
||||
? imgs[0]
|
||||
: null
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { translit } from '../lib/translit'
|
||||
|
||||
export class Tag {
|
||||
public name: string
|
||||
public slug: string
|
||||
|
||||
constructor(tag: string) {
|
||||
this.name = tag
|
||||
|
||||
if (tag) {
|
||||
this.slug = translit(tag).toLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
public isValid() {
|
||||
return !!this.slug
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user