This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0084208
Showing
37 changed files
with
1,235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Output | ||
lib | ||
|
||
### Code ### | ||
# Visual Studio Code - https://code.visualstudio.com/ | ||
.settings/ | ||
.vscode/ | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
#DynamoDB Local files | ||
.dynamodb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 真山 <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# vuepress-plugin-blog | ||
|
||
> Blog plugin for VuePress | ||
## License | ||
|
||
MIT © ULIVZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"name": "vuepress-plugin-blog", | ||
"version": "0.0.0", | ||
"description": "Blog plugin for VuePress", | ||
"scripts": { | ||
"lint": "xo", | ||
"dev": "nodemon --exec ts-node src/index.ts", | ||
"build": "tsc", | ||
"build:w": "tsc --watch", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "conventional-changelog -p angular -r 2 -i CHANGELOG.md -s" | ||
}, | ||
"main": "lib/index.js", | ||
"repository": { | ||
"url": "ulivz/vuepress-plugin-blog", | ||
"type": "git" | ||
}, | ||
"author": "ULIVZ <[email protected]>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"xo": "^0.23.0", | ||
"prettier": "^1.15.2", | ||
"eslint-config-rem": "^4.0.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"eslint-config-xo-typescript": "^0.3.0", | ||
"eslint-plugin-typescript": "^0.14.0", | ||
"typescript-eslint-parser": "^21.0.2", | ||
"husky": "^1.2.0", | ||
"lint-staged": "^8.1.0", | ||
"nodemon": "^1.18.7", | ||
"ts-node": "^7.0.1", | ||
"typescript": "^3.1.4", | ||
"conventional-changelog-cli": "^2.0.1" | ||
}, | ||
"xo": { | ||
"extends": [ | ||
"rem", | ||
"plugin:prettier/recommended", | ||
"xo-typescript" | ||
], | ||
"extensions": [ | ||
"ts" | ||
], | ||
"rules": { | ||
"unicorn/filename-case": "off", | ||
"new-cap": "off", | ||
"typescript/no-inferrable-types": "off", | ||
"import/no-unassigned-import": "off", | ||
"typescript/explicit-function-return-type": "off", | ||
"no-throw-literal": "off" | ||
} | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"linters": { | ||
"*.{ts,js}": [ | ||
"xo --fix", | ||
"git add" | ||
], | ||
"*.{json,md}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
} | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum DefaultLayoutEnum { | ||
FrontmatterClassifier = 'FrontmatterClassifier', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { findPageByKey } from '@app/util' | ||
import frontmatterClassifiedPageMap from '@dynamic/vuepress_blog/frontmatterClassified' | ||
|
||
class Classifiable { | ||
private _metaMap: Record<string, any> | ||
|
||
constructor(metaMap, pages) { | ||
this._metaMap = Object.assign({}, metaMap) | ||
Object.keys(this._metaMap).forEach(name => { | ||
const { pageKeys } = this._metaMap[name] | ||
this._metaMap[name].posts = pageKeys.map(key => findPageByKey(pages, key)) | ||
}) | ||
} | ||
|
||
get length() { | ||
return Object.keys(this._metaMap).length | ||
} | ||
|
||
get map() { | ||
return this._metaMap | ||
} | ||
|
||
get list() { | ||
return this.toArray() | ||
} | ||
|
||
toArray() { | ||
const tags = [] | ||
Object.keys(this._metaMap).forEach(name => { | ||
const { posts, path } = this._metaMap[name] | ||
tags.push({ name, posts, path }) | ||
}) | ||
return tags | ||
} | ||
|
||
getItemByName(name) { | ||
return this._metaMap[name] | ||
} | ||
} | ||
|
||
export default ({ Vue }) => { | ||
console.log(Object.keys(frontmatterClassifiedPageMap)) | ||
const computed = Object.keys(frontmatterClassifiedPageMap) | ||
.map(classifiedType => { | ||
const map = frontmatterClassifiedPageMap[classifiedType] | ||
const helperName = `$${classifiedType}` | ||
return { | ||
[helperName]() { | ||
const { pages } = this.$site | ||
const classified = new Classifiable(map, pages) | ||
return classified | ||
}, | ||
[`$current${classifiedType.charAt(0).toUpperCase() + | ||
classifiedType.slice(1)}`]() { | ||
const tagName = this.$route.meta.frontmatterClassificationKey | ||
return this[helperName].getItemByName(tagName) | ||
}, | ||
} | ||
}) | ||
.reduce((map, item) => { | ||
Object.assign(map, item) | ||
return map | ||
}, {}) | ||
|
||
Vue.mixin({ | ||
computed, | ||
}) | ||
} |
Oops, something went wrong.