diff --git a/.editorconfig b/.editorconfig
new file mode 100755
index 0000000..ea6e20f
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,14 @@
+# http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+insert_final_newline = false
+trim_trailing_whitespace = false
diff --git a/.eslintignore b/.eslintignore
new file mode 100755
index 0000000..289d654
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,3 @@
+styles/
+images/
+node_modules/
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100755
index 0000000..e5ed7e6
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,205 @@
+module.exports = {
+ "env": {
+ "browser": true,
+ "node": true,
+ "es6": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:vue/essential"
+ ],
+ "globals": {
+ "Atomics": "readonly",
+ "SharedArrayBuffer": "readonly"
+ },
+ "parserOptions": {
+ "parser": "babel-eslint",
+ "ecmaVersion": 2018,
+ "sourceType": "module",
+ "allowImportExportEverywhere": true
+ },
+ "plugins": [
+ "vue"
+ ],
+ rules: {
+ "vue/max-attributes-per-line": [2, {
+ "singleline": 10,
+ "multiline": {
+ "max": 1,
+ "allowFirstLine": false
+ }
+ }],
+ "vue/name-property-casing": ["error", "PascalCase"],
+ "vue/html-self-closing": 0,
+ "vue/attributes-order": 0,
+ 'accessor-pairs': 2,
+ 'arrow-spacing': [2, {
+ 'before': true,
+ 'after': true
+ }],
+ 'block-spacing': [2, 'always'],
+ 'brace-style': [2, '1tbs', {
+ 'allowSingleLine': true
+ }],
+ 'camelcase': [0, {
+ 'properties': 'always'
+ }],
+ 'comma-dangle': [2, 'never'],
+ 'comma-spacing': [2, {
+ 'before': false,
+ 'after': true
+ }],
+ 'comma-style': [2, 'last'],
+ 'constructor-super': 2,
+ 'curly': [2, 'multi-line'],
+ 'dot-location': [2, 'property'],
+ 'eol-last': 0,
+ 'eqeqeq': 0,
+ 'generator-star-spacing': [2, {
+ 'before': true,
+ 'after': true
+ }],
+ 'handle-callback-err': [2, '^(err|error)$'],
+ 'indent': ["error", 2, {
+ "SwitchCase": 1
+ }],
+ 'jsx-quotes': [2, 'prefer-single'],
+ 'key-spacing': [2, {
+ 'beforeColon': false,
+ 'afterColon': true
+ }],
+ 'keyword-spacing': [2, {
+ 'before': true,
+ 'after': true
+ }],
+ 'new-cap': [2, {
+ 'newIsCap': true,
+ 'capIsNew': false
+ }],
+ 'new-parens': 2,
+ 'no-array-constructor': 2,
+ 'no-caller': 2,
+ 'no-console': 'off',
+ 'no-class-assign': 2,
+ 'no-cond-assign': 2,
+ 'no-const-assign': 2,
+ 'no-control-regex': 0,
+ 'no-delete-var': 2,
+ 'no-dupe-args': 2,
+ 'no-dupe-class-members': 2,
+ 'no-dupe-keys': 2,
+ 'no-duplicate-case': 2,
+ 'no-empty-character-class': 2,
+ 'no-empty-pattern': 2,
+ 'no-eval': 2,
+ 'no-ex-assign': 2,
+ 'no-extend-native': 2,
+ 'no-extra-bind': 2,
+ 'no-extra-boolean-cast': 2,
+ 'no-extra-parens': [2, 'functions'],
+ 'no-fallthrough': 2,
+ 'no-floating-decimal': 2,
+ 'no-func-assign': 2,
+ 'no-implied-eval': 2,
+ 'no-inner-declarations': [2, 'functions'],
+ 'no-invalid-regexp': 2,
+ 'no-irregular-whitespace': 2,
+ 'no-iterator': 2,
+ 'no-label-var': 2,
+ 'no-labels': [2, {
+ 'allowLoop': false,
+ 'allowSwitch': false
+ }],
+ 'no-lone-blocks': 2,
+ 'no-mixed-spaces-and-tabs': 2,
+ 'no-multi-spaces': 2,
+ 'no-multi-str': 2,
+ 'no-multiple-empty-lines': [2, {
+ 'max': 1
+ }],
+ 'no-native-reassign': 2,
+ 'no-negated-in-lhs': 2,
+ 'no-new-object': 2,
+ 'no-new-require': 2,
+ 'no-new-symbol': 2,
+ 'no-new-wrappers': 2,
+ 'no-obj-calls': 2,
+ 'no-octal': 2,
+ 'no-octal-escape': 2,
+ 'no-path-concat': 2,
+ 'no-proto': 2,
+ 'no-redeclare': 2,
+ 'no-regex-spaces': 2,
+ 'no-return-assign': [2, 'except-parens'],
+ 'no-self-assign': 2,
+ 'no-self-compare': 2,
+ 'no-sequences': 2,
+ 'no-shadow-restricted-names': 2,
+ 'no-spaced-func': 2,
+ 'no-sparse-arrays': 2,
+ 'no-this-before-super': 2,
+ 'no-throw-literal': 2,
+ 'no-trailing-spaces': 2,
+ 'no-undef': 2,
+ 'no-undef-init': 2,
+ 'no-unexpected-multiline': 2,
+ 'no-unmodified-loop-condition': 2,
+ 'no-unneeded-ternary': [2, {
+ 'defaultAssignment': false
+ }],
+ 'no-unreachable': 2,
+ 'no-unsafe-finally': 2,
+ 'no-unused-vars': [2, {
+ 'vars': 'all',
+ 'args': 'none'
+ }],
+ 'no-useless-call': 2,
+ 'no-useless-computed-key': 2,
+ 'no-useless-constructor': 2,
+ 'no-useless-escape': 0,
+ 'no-whitespace-before-property': 2,
+ 'no-with': 2,
+ 'one-var': [2, {
+ 'initialized': 'never'
+ }],
+ 'operator-linebreak': [2, 'after', {
+ 'overrides': {
+ '?': 'before',
+ ':': 'before'
+ }
+ }],
+ 'padded-blocks': [2, 'never'],
+ 'quotes': [2, 'single', {
+ 'avoidEscape': true,
+ 'allowTemplateLiterals': true
+ }],
+ 'semi': [2, 'never'],
+ 'semi-spacing': [2, {
+ 'before': false,
+ 'after': true
+ }],
+ 'space-before-blocks': [2, 'always'],
+ 'space-before-function-paren': [2, 'always'],
+ 'space-in-parens': [2, 'never'],
+ 'space-infix-ops': 2,
+ 'space-unary-ops': [2, {
+ 'words': true,
+ 'nonwords': false
+ }],
+ 'spaced-comment': [2, 'always', {
+ 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
+ }],
+ 'template-curly-spacing': [2, 'never'],
+ 'use-isnan': 2,
+ 'valid-typeof': 2,
+ 'wrap-iife': [2, 'any'],
+ 'yield-star-spacing': [2, 'both'],
+ 'yoda': [2, 'never'],
+ 'prefer-const': 2,
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
+ 'object-curly-spacing': [2, 'always', {
+ objectsInObjects: false
+ }],
+ 'array-bracket-spacing': [2, 'never']
+ }
+};
diff --git a/.gitignore b/.gitignore
index 40b878d..167ab9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-node_modules/
\ No newline at end of file
+node_modules/
+yarn.lock
\ No newline at end of file
diff --git a/components/BackToTop.vue b/components/BackToTop.vue
index b59e690..c6c6e95 100644
--- a/components/BackToTop.vue
+++ b/components/BackToTop.vue
@@ -20,7 +20,7 @@ export default {
},
customStyle: {
type: Object,
- default: function() {
+ default: function () {
return {
right: '1rem',
bottom: '6rem',
@@ -37,27 +37,27 @@ export default {
default: 'fade'
}
},
- data() {
+ data () {
return {
visible: false,
interval: null,
isMoving: false
}
},
- mounted() {
+ mounted () {
window.addEventListener('scroll', this.handleScroll)
},
- beforeDestroy() {
+ beforeDestroy () {
window.removeEventListener('scroll', this.handleScroll)
if (this.interval) {
clearInterval(this.interval)
}
},
methods: {
- handleScroll() {
+ handleScroll () {
this.visible = window.pageYOffset > this.visibilityHeight
},
- backToTop() {
+ backToTop () {
if (this.isMoving) return
const start = window.pageYOffset
let i = 0
@@ -74,7 +74,7 @@ export default {
i++
}, 16.7)
},
- easeInOutQuad(t, b, c, d) {
+ easeInOutQuad (t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b
return -c / 2 * (--t * (t - 2) - 1) + b
}
@@ -88,7 +88,7 @@ export default {
display: inline-block;
text-align: center;
cursor: pointer;
- i
+ i
font-size 1.6rem
color $accentColor
.back-to-ceiling:hover {
diff --git a/components/Common.vue b/components/Common.vue
index a9510b9..caf3dbe 100644
--- a/components/Common.vue
+++ b/components/Common.vue
@@ -25,14 +25,14 @@
-
+
-
+
@@ -46,8 +46,8 @@ import { resolveSidebarItems } from '../util'
import Password from '@theme/components/Password'
import Loading from '@theme/components/Loading'
import Valine from '@theme/components/Valine/'
-import BackToTop from "@theme/components/BackToTop"
-import { setTimeout } from 'timers';
+import BackToTop from '@theme/components/BackToTop'
+import { setTimeout } from 'timers'
export default {
components: { Sidebar, Navbar, Password, Valine, BackToTop, Loading },
@@ -68,26 +68,26 @@ export default {
const { themeConfig } = this.$site
const { frontmatter } = this.$page
if (
- frontmatter.navbar === false
- || themeConfig.navbar === false) {
+ frontmatter.navbar === false ||
+ themeConfig.navbar === false) {
return false
}
return (
- this.$title
- || themeConfig.logo
- || themeConfig.repo
- || themeConfig.nav
- || this.$themeLocaleConfig.nav
+ this.$title ||
+ themeConfig.logo ||
+ themeConfig.repo ||
+ themeConfig.nav ||
+ this.$themeLocaleConfig.nav
)
},
shouldShowSidebar () {
const { frontmatter } = this.$page
return (
- this.sidebar !== false
- && !frontmatter.home
- && frontmatter.sidebar !== false
- && this.sidebarItems.length
+ this.sidebar !== false &&
+ !frontmatter.home &&
+ frontmatter.sidebar !== false &&
+ this.sidebarItems.length
)
},
@@ -127,7 +127,7 @@ export default {
hasKey () {
const keyPage = this.$themeConfig.keyPage
if (!keyPage) {
- this.isHasKey = true
+ this.isHasKey = true
return
}
@@ -137,7 +137,7 @@ export default {
hasPageKey () {
const pageKeys = this.$frontmatter.keys
if (!pageKeys) {
- this.isHasPageKey = true
+ this.isHasPageKey = true
return
}
diff --git a/components/Home.vue b/components/Home.vue
index b775155..ad2c7c2 100644
--- a/components/Home.vue
+++ b/components/Home.vue
@@ -1,10 +1,10 @@
-
{{ data.heroText || $title || '午后南杂' }}
@@ -59,7 +59,7 @@
diff --git a/components/Page.vue b/components/Page.vue
index 756c034..91b8a62 100644
--- a/components/Page.vue
+++ b/components/Page.vue
@@ -75,7 +75,7 @@ import { resolvePage, outboundRE, endingSlashRE } from '../util'
import TimeLine from '@theme/components/TimeLine'
export default {
- components: { PageInfo, TimeLine},
+ components: { PageInfo, TimeLine },
props: ['sidebarItems'],
@@ -92,7 +92,6 @@ export default {
lastUpdated () {
return this.$page.lastUpdated
},
-
lastUpdatedText () {
if (typeof this.$themeLocaleConfig.lastUpdated === 'string') {
return this.$themeLocaleConfig.lastUpdated
@@ -102,7 +101,6 @@ export default {
}
return 'Last Updated'
},
-
prev () {
const prev = this.$frontmatter.prev
if (prev === false) {
@@ -113,7 +111,6 @@ export default {
return resolvePrev(this.$page, this.sidebarItems)
}
},
-
next () {
const next = this.$frontmatter.next
if (next === false) {
@@ -124,10 +121,9 @@ export default {
return resolveNext(this.$page, this.sidebarItems)
}
},
-
editLink () {
if (this.$frontmatter.editLink === false) {
- return
+ return false
}
const {
repo,
@@ -140,13 +136,11 @@ export default {
if (docsRepo && editLinks && this.$page.relativePath) {
return this.createEditLink(repo, docsRepo, docsDir, docsBranch, this.$page.relativePath)
}
+ return ''
},
-
editLinkText () {
return (
- this.$themeLocaleConfig.editLinkText
- || this.$themeConfig.editLinkText
- || `Edit this page`
+ this.$themeLocaleConfig.editLinkText || this.$themeConfig.editLinkText || `Edit this page`
)
}
},
@@ -156,7 +150,7 @@ export default {
const keys = this.$frontmatter.keys
if (!keys) {
- this.isHasKey = true
+ this.isHasKey = true
return
}
@@ -171,12 +165,12 @@ export default {
? docsRepo
: repo
return (
- base.replace(endingSlashRE, '')
- + `/src`
- + `/${docsBranch}/`
- + (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
- + path
- + `?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default`
+ base.replace(endingSlashRE, '') +
+ `/src` +
+ `/${docsBranch}/` +
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') +
+ path +
+ `?mode=edit&spa=0&at=${docsBranch}&fileviewer=file-view-default`
)
}
@@ -184,11 +178,11 @@ export default {
? docsRepo
: `https://github.com/${docsRepo}`
return (
- base.replace(endingSlashRE, '')
- + `/edit`
- + `/${docsBranch}/`
- + (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '')
- + path
+ base.replace(endingSlashRE, '') +
+ `/edit` +
+ `/${docsBranch}/` +
+ (docsDir ? docsDir.replace(endingSlashRE, '') + '/' : '') +
+ path
)
}
}
@@ -236,7 +230,7 @@ function flatten (items, res) {
#time-line {
margin-top 0
padding-top 0
- }
+ }
.page-title
max-width: 740px;
margin: 0 auto;
@@ -265,7 +259,7 @@ function flatten (items, res) {
}
&.reco-show.page {
load-end(0.08s)
- }
+ }
.page-nav
@extend $wrapper
@@ -280,10 +274,9 @@ function flatten (items, res) {
.next
float right
-
@media (max-width: $MQMobile)
.page-title
- padding: 0 1rem;
+ padding: 0 1rem;
.page-edit
.edit-link
margin-bottom .5rem
diff --git a/components/PageInfo.vue b/components/PageInfo.vue
index a30c87e..010f634 100644
--- a/components/PageInfo.vue
+++ b/components/PageInfo.vue
@@ -29,7 +29,9 @@ export default {
props: {
pageInfo: {
type: Object,
- default: {}
+ default () {
+ return {}
+ }
},
currentTag: {
type: String,
@@ -49,7 +51,7 @@ export default {
}
}
},
-
+
methods: {
goTags (tag) {
const base = this.$site.base
@@ -66,7 +68,7 @@ export default {
line-height 1.5rem
&:not(:last-child)
margin-right 1rem
- span
+ span
margin-left .5rem
.tags
.tag-item
@@ -74,7 +76,7 @@ export default {
font-family Ubuntu, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif
&.active
color $accentColor
- &:hover
+ &:hover
color $accentColor
@media (max-width: $MQMobile)
diff --git a/components/Password.vue b/components/Password.vue
index 69d7683..1b52d71 100644
--- a/components/Password.vue
+++ b/components/Password.vue
@@ -35,7 +35,7 @@
import Background from '@theme/components/Background'
export default {
- components: {Background},
+ components: { Background },
props: {
isPage: {
type: Boolean,
@@ -43,7 +43,7 @@ export default {
}
},
name: 'Password',
- data() {
+ data () {
return {
warningText: 'Konck! Knock!',
key: ''
@@ -63,14 +63,14 @@ export default {
if (!isHasKey) {
this.warningText = 'Key Error'
return
- }
+ }
const passwordBtn = this.$refs.passwordBtn
const width = document.getElementById('box').getClientRects()[0].width
passwordBtn.style.width = `${width - 2}px`
passwordBtn.style.opacity = 1
setTimeout(() => {
- window.location.reload();
+ window.location.reload()
}, 800)
},
isHasKey () {
@@ -221,7 +221,7 @@ export default {
margin-left 1rem
> i {
margin-right .5rem
- }
+ }
}
}
@media (max-width: $MQMobile) {
diff --git a/components/ScreenFull.vue b/components/ScreenFull.vue
index d32973b..1216552 100644
--- a/components/ScreenFull.vue
+++ b/components/ScreenFull.vue
@@ -8,19 +8,19 @@
import screenfull from 'screenfull'
export default {
name: 'Screenfull',
- data() {
+ data () {
return {
isFullscreen: false
}
},
- mounted() {
+ mounted () {
this.init()
},
- beforeDestroy() {
+ beforeDestroy () {
this.destroy()
},
methods: {
- click() {
+ click () {
if (!screenfull.enabled) {
this.$message({
message: 'you browser can not work',
@@ -30,15 +30,15 @@ export default {
}
screenfull.toggle()
},
- change() {
+ change () {
this.isFullscreen = screenfull.isFullscreen
},
- init() {
+ init () {
if (screenfull.enabled) {
screenfull.on('change', this.change)
}
},
- destroy() {
+ destroy () {
if (screenfull.enabled) {
screenfull.off('change', this.change)
}
diff --git a/components/SidebarLink.vue b/components/SidebarLink.vue
index 3f5e6eb..da42b89 100644
--- a/components/SidebarLink.vue
+++ b/components/SidebarLink.vue
@@ -30,15 +30,15 @@ export default {
: selfActive
const link = renderLink(h, item.path, item.title || item.path, active)
- const configDepth = $page.frontmatter.sidebarDepth
- || sidebarDepth
- || $themeLocaleConfig.sidebarDepth
- || $themeConfig.sidebarDepth
+ const configDepth = $page.frontmatter.sidebarDepth ||
+ sidebarDepth ||
+ $themeLocaleConfig.sidebarDepth ||
+ $themeConfig.sidebarDepth
const maxDepth = configDepth == null ? 1 : configDepth
- const displayAllHeaders = $themeLocaleConfig.displayAllHeaders
- || $themeConfig.displayAllHeaders
+ const displayAllHeaders = $themeLocaleConfig.displayAllHeaders ||
+ $themeConfig.displayAllHeaders
if (item.type === 'auto') {
return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)]
diff --git a/components/SidebarLinks.vue b/components/SidebarLinks.vue
index dfdb0be..c60c41f 100644
--- a/components/SidebarLinks.vue
+++ b/components/SidebarLinks.vue
@@ -33,7 +33,7 @@ export default {
props: [
'items',
- 'depth', // depth of current sidebar links
+ 'depth', // depth of current sidebar links
'sidebarDepth' // depth of headers to be extracted
],
diff --git a/components/Theme/ThemeOptions.vue b/components/Theme/ThemeOptions.vue
index 0fc5bc1..1a305b2 100755
--- a/components/Theme/ThemeOptions.vue
+++ b/components/Theme/ThemeOptions.vue
@@ -14,55 +14,54 @@
diff --git a/index.js b/index.js
index c9e26bd..173cccb 100644
--- a/index.js
+++ b/index.js
@@ -6,8 +6,8 @@ module.exports = (options, ctx) => ({
const { themeConfig, siteConfig } = ctx
// resolve algolia
const isAlgoliaSearch = (
- themeConfig.algolia
- || Object.keys(siteConfig.locales && themeConfig.locales || {})
+ themeConfig.algolia ||
+ Object.keys(siteConfig.locales && themeConfig.locales || {})
.some(base => themeConfig.locales[base].algolia)
)
return {
diff --git a/layouts/404.vue b/layouts/404.vue
index 7c8b1c9..6386674 100644
--- a/layouts/404.vue
+++ b/layouts/404.vue
@@ -24,7 +24,7 @@ export default {
},
mounted () {
if (this.noFoundPageByTencent) {
- let dom = document.createElement('script')
+ const dom = document.createElement('script')
dom.setAttribute('homePageName', '回到首页')
dom.setAttribute('homePageUrl', '/')
dom.setAttribute('src', '//qzonestyle.gtimg.cn/qzone/hybrid/app/404/search_children.js')
diff --git a/layouts/Category.vue b/layouts/Category.vue
index 749b9e2..abf0da5 100644
--- a/layouts/Category.vue
+++ b/layouts/Category.vue
@@ -4,10 +4,10 @@
- -
{{ item.name }}
@@ -17,14 +17,14 @@
-
-
+
- {
return this._getTimeNum(b) - this._getTimeNum(a)
})
@@ -94,7 +94,7 @@ export default {
.categories-wrapper
max-width: 740px;
margin: 0 auto;
- padding: 4.6rem 2.5rem 0;
+ padding: 4.6rem 2.5rem 0;
.category-wrapper {
list-style none
padding-left 0
@@ -151,7 +151,7 @@ export default {
.pagation {
load-end(0.24s)
}
- }
+ }
@media (max-width: $MQMobile)
.categories-wrapper
diff --git a/layouts/Tags.vue b/layouts/Tags.vue
index 2421864..aa58701 100644
--- a/layouts/Tags.vue
+++ b/layouts/Tags.vue
@@ -2,21 +2,21 @@