Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit e8c5c6b

Browse files
committed
style: lint code
1 parent 6aabec6 commit e8c5c6b

19 files changed

+579
-535
lines changed

src/client/classification.ts

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,93 @@
11
// @ts-ignore
2-
import { findPageByKey } from '@app/util'
2+
import { findPageByKey } from '@app/util';
33
// @ts-ignore
4-
import frontmatterClassifiedMap from '@dynamic/vuepress_blog/frontmatterClassified'
5-
import { VuePressPage } from '../types/VuePress'
4+
import frontmatterClassifiedMap from '@dynamic/vuepress_blog/frontmatterClassified';
5+
import { VuePressPage } from '../types/VuePress';
66

77
class Classifiable {
8-
private _metaMap: any
8+
private _metaMap: any;
99

1010
constructor(metaMap, pages) {
11-
this._metaMap = Object.assign({}, metaMap)
11+
this._metaMap = Object.assign({}, metaMap);
1212
Object.keys(this._metaMap).forEach(name => {
13-
const { pageKeys } = this._metaMap[name]
14-
this._metaMap[name].pages = pageKeys.map(key => findPageByKey(pages, key))
15-
})
13+
const { pageKeys } = this._metaMap[name];
14+
this._metaMap[name].pages = pageKeys.map(key =>
15+
findPageByKey(pages, key)
16+
);
17+
});
1618
}
1719

1820
get length() {
19-
return Object.keys(this._metaMap).length
21+
return Object.keys(this._metaMap).length;
2022
}
2123

2224
get map() {
23-
return this._metaMap
25+
return this._metaMap;
2426
}
2527

2628
get pages() {
27-
return this.list
29+
return this.list;
2830
}
2931

3032
get list() {
31-
return this.toArray()
33+
return this.toArray();
3234
}
3335

3436
toArray() {
3537
const tags: Array<{
36-
name: string
37-
pages: VuePressPage[]
38-
path: string
39-
}> = []
38+
name: string;
39+
pages: VuePressPage[];
40+
path: string;
41+
}> = [];
4042

4143
Object.keys(this._metaMap).forEach(name => {
42-
const { pages, path } = this._metaMap[name]
43-
tags.push({ name, pages, path })
44-
})
45-
return tags
44+
const { pages, path } = this._metaMap[name];
45+
tags.push({ name, pages, path });
46+
});
47+
return tags;
4648
}
4749

4850
getItemByName(name) {
49-
return this._metaMap[name]
51+
return this._metaMap[name];
5052
}
5153
}
5254

5355
export default ({ Vue }) => {
5456
const computed = Object.keys(frontmatterClassifiedMap)
5557
.map(classifiedType => {
56-
const map = frontmatterClassifiedMap[classifiedType]
57-
const helperName = `$${classifiedType}`
58+
const map = frontmatterClassifiedMap[classifiedType];
59+
const helperName = `$${classifiedType}`;
5860
return {
5961
[helperName]() {
6062
// @ts-ignore
61-
const { pages } = this.$site
62-
const classified = new Classifiable(map, pages)
63-
return classified
63+
const { pages } = this.$site;
64+
const classified = new Classifiable(map, pages);
65+
return classified;
6466
},
6567
[`$current${classifiedType.charAt(0).toUpperCase() +
6668
classifiedType.slice(1)}`]() {
6769
// @ts-ignore
68-
const tagName = this.$route.meta.id
70+
const tagName = this.$route.meta.id;
6971
// @ts-ignore
70-
return this[helperName].getItemByName(tagName)
72+
return this[helperName].getItemByName(tagName);
7173
},
72-
}
74+
};
7375
})
7476
.reduce((map, item) => {
75-
Object.assign(map, item)
76-
return map
77-
}, {})
77+
Object.assign(map, item);
78+
return map;
79+
}, {});
7880

7981
computed.$frontmatterKey = function() {
8082
// @ts-ignore
81-
const target = this[`$${this.$route.meta.id}`]
83+
const target = this[`$${this.$route.meta.id}`];
8284
if (target) {
83-
return target
85+
return target;
8486
}
85-
return null
86-
}
87+
return null;
88+
};
8789

8890
Vue.mixin({
8991
computed,
90-
})
91-
}
92+
});
93+
};

src/client/components.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @ts-ignore
2-
import Pagination from './components/Pagination.vue'
2+
import Pagination from './components/Pagination.vue';
33
// @ts-ignore
4-
import SimplePagination from './components/SimplePagination.vue'
4+
import SimplePagination from './components/SimplePagination.vue';
55
// @ts-ignore
6-
import Comment from './components/Comment.vue'
6+
import Comment from './components/Comment.vue';
77

8-
export { Pagination, SimplePagination, Comment }
8+
export { Pagination, SimplePagination, Comment };

src/client/components/Comment.vue

Lines changed: 74 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,89 @@
11
<template>
2-
<Vssue
3-
v-if="commentService === 'vssue'"
4-
v-bind="vssueProps"
5-
/>
6-
<vue-disqus
7-
v-else-if="commentService === 'disqus'"
8-
v-bind="disqusProps"
9-
/>
2+
<Vssue v-if="commentService === 'vssue'" v-bind="vssueProps" />
3+
<vue-disqus v-else-if="commentService === 'disqus'" v-bind="disqusProps" />
104
</template>
115

126
<script>
13-
import identity from 'lodash/identity'
14-
import pickBy from 'lodash/pickBy'
7+
import identity from 'lodash/identity';
8+
import pickBy from 'lodash/pickBy';
159
16-
export default {
17-
props: {
18-
// vssue's props
19-
title: {
20-
type: String | Function,
21-
required: false
22-
},
23-
issueId: {
24-
type: String | Number,
25-
required: false
26-
},
27-
options: {
28-
type: Object,
29-
required: false
30-
},
31-
// vue-disqus's props
32-
shortname: {
33-
type: String,
34-
required: false
35-
},
36-
identifier: {
37-
type: String,
38-
required: false
39-
},
40-
url: {
41-
type: String,
42-
required: false
43-
},
44-
title: {
45-
type: String,
46-
required: false
47-
},
48-
remote_auth_s3: {
49-
type: String,
50-
required: false
51-
},
52-
api_key: {
53-
type: String,
54-
required: false
55-
},
56-
sso_config: {
57-
type: Object,
58-
required: false
59-
},
60-
language: {
61-
type: String,
62-
required: false
63-
}
10+
export default {
11+
props: {
12+
// vssue's props
13+
title: {
14+
type: [String, Function],
15+
required: false,
6416
},
65-
66-
data () {
67-
return {
68-
commentService: COMMENT_SERVICE
69-
}
17+
issueId: {
18+
type: [String, Number],
19+
required: false,
20+
},
21+
options: {
22+
type: Object,
23+
required: false,
24+
},
25+
// vue-disqus's props
26+
shortname: {
27+
type: String,
28+
required: false,
29+
},
30+
identifier: {
31+
type: String,
32+
required: false,
33+
},
34+
url: {
35+
type: String,
36+
required: false,
37+
},
38+
remote_auth_s3: {
39+
type: String,
40+
required: false,
41+
},
42+
api_key: {
43+
type: String,
44+
required: false,
7045
},
46+
sso_config: {
47+
type: Object,
48+
required: false,
49+
},
50+
language: {
51+
type: String,
52+
required: false,
53+
},
54+
},
7155
72-
computed: {
73-
propsWithoutEmptyProperties () {
74-
return pickBy(this.$props, identity);
75-
},
56+
data() {
57+
return {
58+
commentService: COMMENT_SERVICE,
59+
};
60+
},
7661
77-
commentProps () {
78-
return Object.assign({}, this.propsWithoutEmptyProperties, this.$frontmatter.comment)
79-
},
62+
computed: {
63+
propsWithoutEmptyProperties() {
64+
return pickBy(this.$props, identity);
65+
},
8066
81-
vssueProps () {
82-
return Object.assign({ title: this.$page.title }, this.commentProps)
83-
},
67+
commentProps() {
68+
return Object.assign(
69+
{},
70+
this.propsWithoutEmptyProperties,
71+
this.$frontmatter.comment
72+
);
73+
},
8474
85-
disqusProps () {
86-
return Object.assign({ identifier: this.$page.key }, this.commentProps)
87-
}
75+
vssueProps() {
76+
return Object.assign({ title: this.$page.title }, this.commentProps);
8877
},
8978
90-
mounted () {
91-
if (typeof COMMENT_SERVICE === 'undefined') console.warn("There's no comment service!")
79+
disqusProps() {
80+
return Object.assign({ identifier: this.$page.key }, this.commentProps);
9281
},
93-
}
94-
</script>
82+
},
9583
84+
mounted() {
85+
if (typeof COMMENT_SERVICE === 'undefined')
86+
console.warn("There's no comment service!");
87+
},
88+
};
89+
</script>

0 commit comments

Comments
 (0)