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

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Jun 2, 2019
0 parents commit 0084208
Show file tree
Hide file tree
Showing 37 changed files with 1,235 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
116 changes: 116 additions & 0 deletions .gitignore
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/
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
21 changes: 21 additions & 0 deletions LICENSE
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.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# vuepress-plugin-blog

> Blog plugin for VuePress
## License

MIT &copy; ULIVZ
74 changes: 74 additions & 0 deletions package.json
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/"
}
}
3 changes: 3 additions & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum DefaultLayoutEnum {
FrontmatterClassifier = 'FrontmatterClassifier',
}
68 changes: 68 additions & 0 deletions src/client/classification.ts
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,
})
}
Loading

0 comments on commit 0084208

Please sign in to comment.