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

Commit 0084208

Browse files
committed
feat: init
0 parents  commit 0084208

37 files changed

+1235
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Output
2+
lib
3+
4+
### Code ###
5+
# Visual Studio Code - https://code.visualstudio.com/
6+
.settings/
7+
.vscode/
8+
9+
### macOS ###
10+
# General
11+
.DS_Store
12+
.AppleDouble
13+
.LSOverride
14+
15+
# Icon must end with two \r
16+
Icon
17+
18+
# Thumbnails
19+
._*
20+
21+
# Files that might appear in the root of a volume
22+
.DocumentRevisions-V100
23+
.fseventsd
24+
.Spotlight-V100
25+
.TemporaryItems
26+
.Trashes
27+
.VolumeIcon.icns
28+
.com.apple.timemachine.donotpresent
29+
30+
# Directories potentially created on remote AFP share
31+
.AppleDB
32+
.AppleDesktop
33+
Network Trash Folder
34+
Temporary Items
35+
.apdisk
36+
37+
### Node ###
38+
# Logs
39+
logs
40+
*.log
41+
npm-debug.log*
42+
yarn-debug.log*
43+
yarn-error.log*
44+
45+
# Runtime data
46+
pids
47+
*.pid
48+
*.seed
49+
*.pid.lock
50+
51+
# Directory for instrumented libs generated by jscoverage/JSCover
52+
lib-cov
53+
54+
# Coverage directory used by tools like istanbul
55+
coverage
56+
57+
# nyc test coverage
58+
.nyc_output
59+
60+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
61+
.grunt
62+
63+
# Bower dependency directory (https://bower.io/)
64+
bower_components
65+
66+
# node-waf configuration
67+
.lock-wscript
68+
69+
# Compiled binary addons (https://nodejs.org/api/addons.html)
70+
build/Release
71+
72+
# Dependency directories
73+
node_modules/
74+
jspm_packages/
75+
76+
# TypeScript v1 declaration files
77+
typings/
78+
79+
# Optional npm cache directory
80+
.npm
81+
82+
# Optional eslint cache
83+
.eslintcache
84+
85+
# Optional REPL history
86+
.node_repl_history
87+
88+
# Output of 'npm pack'
89+
*.tgz
90+
91+
# Yarn Integrity file
92+
.yarn-integrity
93+
94+
# dotenv environment variables file
95+
.env
96+
97+
# parcel-bundler cache (https://parceljs.org/)
98+
.cache
99+
100+
# next.js build output
101+
.next
102+
103+
# nuxt.js build output
104+
.nuxt
105+
106+
# vuepress build output
107+
.vuepress/dist
108+
109+
# Serverless directories
110+
.serverless/
111+
112+
# FuseBox cache
113+
.fusebox/
114+
115+
#DynamoDB Local files
116+
.dynamodb/

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 真山 <haoli.chl@antfin.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# vuepress-plugin-blog
2+
3+
> Blog plugin for VuePress
4+
5+
## License
6+
7+
MIT &copy; ULIVZ

package.json

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "vuepress-plugin-blog",
3+
"version": "0.0.0",
4+
"description": "Blog plugin for VuePress",
5+
"scripts": {
6+
"lint": "xo",
7+
"dev": "nodemon --exec ts-node src/index.ts",
8+
"build": "tsc",
9+
"build:w": "tsc --watch",
10+
"prepare": "npm run build",
11+
"prepublishOnly": "conventional-changelog -p angular -r 2 -i CHANGELOG.md -s"
12+
},
13+
"main": "lib/index.js",
14+
"repository": {
15+
"url": "ulivz/vuepress-plugin-blog",
16+
"type": "git"
17+
},
18+
"author": "ULIVZ <chl814@foxmail.com>",
19+
"license": "MIT",
20+
"devDependencies": {
21+
"xo": "^0.23.0",
22+
"prettier": "^1.15.2",
23+
"eslint-config-rem": "^4.0.0",
24+
"eslint-config-prettier": "^3.3.0",
25+
"eslint-plugin-prettier": "^3.0.0",
26+
"eslint-config-xo-typescript": "^0.3.0",
27+
"eslint-plugin-typescript": "^0.14.0",
28+
"typescript-eslint-parser": "^21.0.2",
29+
"husky": "^1.2.0",
30+
"lint-staged": "^8.1.0",
31+
"nodemon": "^1.18.7",
32+
"ts-node": "^7.0.1",
33+
"typescript": "^3.1.4",
34+
"conventional-changelog-cli": "^2.0.1"
35+
},
36+
"xo": {
37+
"extends": [
38+
"rem",
39+
"plugin:prettier/recommended",
40+
"xo-typescript"
41+
],
42+
"extensions": [
43+
"ts"
44+
],
45+
"rules": {
46+
"unicorn/filename-case": "off",
47+
"new-cap": "off",
48+
"typescript/no-inferrable-types": "off",
49+
"import/no-unassigned-import": "off",
50+
"typescript/explicit-function-return-type": "off",
51+
"no-throw-literal": "off"
52+
}
53+
},
54+
"husky": {
55+
"hooks": {
56+
"pre-commit": "lint-staged"
57+
}
58+
},
59+
"lint-staged": {
60+
"linters": {
61+
"*.{ts,js}": [
62+
"xo --fix",
63+
"git add"
64+
],
65+
"*.{json,md}": [
66+
"prettier --write",
67+
"git add"
68+
]
69+
}
70+
},
71+
"publishConfig": {
72+
"registry": "https://registry.npmjs.org/"
73+
}
74+
}

src/Config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum DefaultLayoutEnum {
2+
FrontmatterClassifier = 'FrontmatterClassifier',
3+
}

src/client/classification.ts

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { findPageByKey } from '@app/util'
2+
import frontmatterClassifiedPageMap from '@dynamic/vuepress_blog/frontmatterClassified'
3+
4+
class Classifiable {
5+
private _metaMap: Record<string, any>
6+
7+
constructor(metaMap, pages) {
8+
this._metaMap = Object.assign({}, metaMap)
9+
Object.keys(this._metaMap).forEach(name => {
10+
const { pageKeys } = this._metaMap[name]
11+
this._metaMap[name].posts = pageKeys.map(key => findPageByKey(pages, key))
12+
})
13+
}
14+
15+
get length() {
16+
return Object.keys(this._metaMap).length
17+
}
18+
19+
get map() {
20+
return this._metaMap
21+
}
22+
23+
get list() {
24+
return this.toArray()
25+
}
26+
27+
toArray() {
28+
const tags = []
29+
Object.keys(this._metaMap).forEach(name => {
30+
const { posts, path } = this._metaMap[name]
31+
tags.push({ name, posts, path })
32+
})
33+
return tags
34+
}
35+
36+
getItemByName(name) {
37+
return this._metaMap[name]
38+
}
39+
}
40+
41+
export default ({ Vue }) => {
42+
console.log(Object.keys(frontmatterClassifiedPageMap))
43+
const computed = Object.keys(frontmatterClassifiedPageMap)
44+
.map(classifiedType => {
45+
const map = frontmatterClassifiedPageMap[classifiedType]
46+
const helperName = `$${classifiedType}`
47+
return {
48+
[helperName]() {
49+
const { pages } = this.$site
50+
const classified = new Classifiable(map, pages)
51+
return classified
52+
},
53+
[`$current${classifiedType.charAt(0).toUpperCase() +
54+
classifiedType.slice(1)}`]() {
55+
const tagName = this.$route.meta.frontmatterClassificationKey
56+
return this[helperName].getItemByName(tagName)
57+
},
58+
}
59+
})
60+
.reduce((map, item) => {
61+
Object.assign(map, item)
62+
return map
63+
}, {})
64+
65+
Vue.mixin({
66+
computed,
67+
})
68+
}

0 commit comments

Comments
 (0)