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

Commit 06c5afa

Browse files
committed
build: refine source code structure to reach full typescript
1 parent a49fa3d commit 06c5afa

28 files changed

+189
-159
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
lib
33
.temp
44
types
5+
src/**/*.js
56

67
### Code ###
78
# Visual Studio Code - https://code.visualstudio.com/

examples/blog/.vuepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
title: `ULIVZ`,
33
plugins: [
4-
[require('../../../lib'), {
4+
[require('../../../lib/node'), {
55
directories: [
66
{
77
// Unique ID of current classification

examples/blog/.vuepress/theme/layouts/Layout.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
<router-link v-if="$pagination.hasPrev" :to="$pagination.prevLink">Prev</router-link>
1010
<router-link v-if="$pagination.hasNext" :to="$pagination.nextLink">Next</router-link>
1111
</div>
12-
13-
<Pagination />
12+
13+
<Pagination/>
1414
</div>
1515
</template>
1616

1717
<script>
18-
import Pagination from '../../../../../src/components/Pagination'
18+
import { Pagination } from '../../../../../lib/client/components.js'
1919
2020
export default {
2121
components: { Pagination },
2222
created() {
2323
console.log(this.$route.meta.pid)
2424
console.log(this.$currentTag)
25-
}
25+
},
2626
}
2727
</script>

examples/directory-classifier/.vuepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
title: `ULIVZ`,
33
plugins: [
4-
[require('../../../lib'), {
4+
[require('../../../lib/node'), {
55
directories: [
66
{
77
// Unique ID of current classification

examples/frontmatter-classifier/.vuepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
title: `ULIVZ`,
33
plugins: [
4-
[require('../../../lib'), {
4+
[require('../../../lib/node'), {
55
frontmatters: [
66
{
77
// Unique ID of current classification

package.json

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44
"description": "Offical blog plugin for VuePress",
55
"scripts": {
66
"lint": "xo",
7-
"dev": "npm run cpc && tsc -skipLibCheck --watch",
8-
"cpc": "cp -r src/client lib",
9-
"build": "tsc -skipLibCheck && npm run cpc",
7+
"dev": "concurrently \"yarn dev:client\" \"yarn dev:node\" \"yarn build:components\"",
8+
"build": "concurrently \"yarn build:client\" \"yarn build:node\" \"yarn build:components\"",
9+
"dev:client": "tsc -p tsconfig.client.json --watch",
10+
"dev:node": "tsc -p tsconfig.node.json --watch",
11+
"build:client": "tsc -p tsconfig.client.json",
12+
"build:node": "tsc -p tsconfig.node.json",
13+
"build:components": "mkdir -p lib/client/components && cp -r src/client/components lib/client",
1014
"dev:docs": "vuepress dev docs --temp docs/.temp",
1115
"build:docs": "vuepress build docs --temp docs/.temp",
1216
"example": "node examples/launch.js",
1317
"prepare": "npm run build",
1418
"prepublishOnly": "npm run build && conventional-changelog -p angular -r 2 -i CHANGELOG.md -s"
1519
},
16-
"main": "lib/index.js",
20+
"main": "lib/node/index.js",
1721
"files": [
1822
"lib",
1923
"docs",
@@ -25,24 +29,17 @@
2529
},
2630
"author": "ULIVZ <[email protected]>",
2731
"license": "MIT",
32+
"dependencies": {
33+
"vuejs-paginate": "^2.1.0"
34+
},
2835
"devDependencies": {
36+
"concurrently": "^4.1.0",
2937
"conventional-changelog-cli": "^2.0.1",
30-
"eslint-config-prettier": "^3.3.0",
31-
"eslint-config-rem": "^4.0.0",
32-
"eslint-config-xo-typescript": "^0.3.0",
33-
"eslint-plugin-prettier": "^3.0.0",
34-
"eslint-plugin-typescript": "^0.14.0",
35-
"husky": "^1.2.0",
3638
"inquirer": "^6.3.1",
37-
"lint-staged": "^8.1.0",
3839
"nodemon": "^1.18.7",
39-
"prettier": "^1.15.2",
4040
"ts-node": "^7.0.1",
41-
"typescript": "^3.1.4",
42-
"typescript-eslint-parser": "^21.0.2",
43-
"vuejs-paginate": "^2.1.0",
44-
"vuepress": "^1.0.0",
45-
"xo": "^0.23.0"
41+
"typescript": "3.1.4",
42+
"vuepress": "^1.0.0"
4643
},
4744
"xo": {
4845
"extends": [
@@ -63,24 +60,9 @@
6360
"typescript/no-var-requires": "off",
6461
"no-implicit-globals": "off",
6562
"import/no-unresolved": "off",
66-
"import/no-extraneous-dependencies": "off"
67-
}
68-
},
69-
"husky": {
70-
"hooks": {
71-
"pre-commit": "lint-staged"
72-
}
73-
},
74-
"lint-staged": {
75-
"linters": {
76-
"*.{ts,js}": [
77-
"xo --fix",
78-
"git add"
79-
],
80-
"*.{json,md}": [
81-
"prettier --write",
82-
"git add"
83-
]
63+
"import/no-extraneous-dependencies": "off",
64+
"typescript/no-use-before-define": "off",
65+
"typescript/no-type-alias": "off"
8466
}
8567
},
8668
"publishConfig": {

src/client/classification.js renamed to src/client/classification.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
// @ts-ignore
12
import { findPageByKey } from '@app/util'
2-
import frontmatterClassifiedPageMap from '@dynamic/vuepress_blog/frontmatterClassified'
3+
// @ts-ignore
4+
import frontmatterClassifiedMap from '@dynamic/vuepress_blog/frontmatterClassified'
5+
import { VuePressPage } from '../types/VuePress'
36

47
class Classifiable {
8+
private _metaMap: any
9+
510
constructor(metaMap, pages) {
611
this._metaMap = Object.assign({}, metaMap)
712
Object.keys(this._metaMap).forEach(name => {
@@ -27,7 +32,12 @@ class Classifiable {
2732
}
2833

2934
toArray() {
30-
const tags = []
35+
const tags: Array<{
36+
name: string
37+
pages: VuePressPage[]
38+
path: string
39+
}> = []
40+
3141
Object.keys(this._metaMap).forEach(name => {
3242
const { pages, path } = this._metaMap[name]
3343
tags.push({ name, pages, path })
@@ -41,18 +51,22 @@ class Classifiable {
4151
}
4252

4353
export default ({ Vue }) => {
44-
const computed = Object.keys(frontmatterClassifiedPageMap)
54+
const computed = Object.keys(frontmatterClassifiedMap)
4555
.map(classifiedType => {
46-
const map = frontmatterClassifiedPageMap[classifiedType]
56+
const map = frontmatterClassifiedMap[classifiedType]
4757
const helperName = `$${classifiedType}`
4858
return {
4959
[helperName]() {
60+
// @ts-ignore
5061
const { pages } = this.$site
5162
const classified = new Classifiable(map, pages)
5263
return classified
5364
},
54-
[`$current${classifiedType.charAt(0).toUpperCase() + classifiedType.slice(1)}`]() {
65+
[`$current${classifiedType.charAt(0).toUpperCase() +
66+
classifiedType.slice(1)}`]() {
67+
// @ts-ignore
5568
const tagName = this.$route.meta.id
69+
// @ts-ignore
5670
return this[helperName].getItemByName(tagName)
5771
},
5872
}

src/client/components.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @ts-ignore
2+
import Pagination from './components/Pagination.vue'
3+
// @ts-ignore
4+
import SimplePagination from './components/SimplePagination.vue'
5+
6+
export { Pagination, SimplePagination }

src/components/Pagination.vue renamed to src/client/components/Pagination.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@
1212

1313
<script>
1414
import Paginate from 'vuejs-paginate'
15-
15+
1616
export default {
1717
data() {
1818
return {
1919
page: 0,
2020
}
2121
},
2222
components: { Paginate },
23+
created() {
24+
this.page = this.$pagination.paginationIndex + 1
25+
},
2326
methods: {
2427
clickCallback(pageNum) {
2528
const link = this.$pagination.getSpecificPageLink(pageNum - 1)
26-
console.log(link)
2729
this.$router.push(link)
2830
},
2931
},

0 commit comments

Comments
 (0)