Run fixlint

parent ee60bf17
......@@ -26,7 +26,7 @@ export default {
required: true
}
},
data() {
data () {
return {
open: true
}
......
......@@ -28,8 +28,6 @@
</template>
<script>
import { timeAgo } from '~/plugins/filters'
export default {
name: 'NewsItem',
props: {
......@@ -39,7 +37,7 @@ export default {
}
},
methods: {
isAbsolute(url) {
isAbsolute (url) {
return /^https?:\/\//.test(url)
}
}
......
......@@ -29,7 +29,7 @@ export default {
}
},
computed: {
hasMore() {
hasMore () {
return this.page < this.maxPage
}
}
......
......@@ -9,7 +9,7 @@ export default {
default: false
}
},
render(h, { props, children }) {
render (h, { props, children }) {
return props.loading
? h('div', { style: { 'text-align': 'center' } }, [
h(Spinner, { props: { show: true } })
......
......@@ -21,7 +21,7 @@
import { feeds } from '~/common/api'
export default {
head() {
head () {
const host = process.server
? this.$ssrContext.req.headers.host
: window.location.host
......
......@@ -44,7 +44,7 @@ export default {
},
static: {
maxAge: '1y',
setHeaders(res, path) {
setHeaders (res, path) {
if (path.includes('sw.js')) {
res.setHeader('Cache-Control', `public, max-age=${15 * 60}`)
}
......
......@@ -28,11 +28,11 @@ export default {
LazyWrapper
},
validate({ params: { feed } }) {
validate ({ params: { feed } }) {
return validFeeds.includes(feed)
},
data() {
data () {
return {
transition: 'slide-right',
displayedPage: Number(this.page) || 1
......@@ -40,22 +40,22 @@ export default {
},
computed: {
feed() {
feed () {
return this.$route.params.feed
},
page() {
page () {
return Number(this.$route.params.page) || 1
},
maxPage() {
maxPage () {
return feeds[this.feed].pages
},
pageData() {
pageData () {
return this.$store.state.feeds[this.feed][this.page]
},
displayedItems() {
displayedItems () {
return this.pageData.map(id => this.$store.state.items[id])
},
loading() {
loading () {
return this.displayedItems.length === 0
}
},
......@@ -64,23 +64,23 @@ export default {
page: 'pageChanged'
},
fetch({ store, params: { feed, page = 1 } }) {
fetch ({ store, params: { feed, page = 1 } }) {
page = Number(page) || 1
return store.dispatch('FETCH_FEED', { feed, page })
},
head() {
head () {
return {
title: feeds[this.$route.params.feed].title
}
},
mounted() {
mounted () {
this.pageChanged(this.page)
},
methods: {
pageChanged(to, from = -1) {
pageChanged (to, from = -1) {
if (to <= 0 || to > this.maxPage) {
this.$router.replace(`/${this.feed}/1`)
return
......
......@@ -2,7 +2,7 @@
import { validFeeds } from '~/common/api'
export default {
fetch({ redirect }) {
fetch ({ redirect }) {
redirect('/' + validFeeds[0])
}
}
......
......@@ -37,27 +37,27 @@ export default {
name: 'ItemView',
components: { Comment, LazyWrapper },
head() {
head () {
return {
title: this.item.title
}
},
computed: {
id() {
id () {
return this.$route.params.id
},
item() {
item () {
return this.$store.state.items[this.id]
}
},
fetch({ store, params: { id } }) {
fetch ({ store, params: { id } }) {
return store.dispatch('FETCH_ITEM', { id })
},
methods: {
isAbsolute(url) {
isAbsolute (url) {
return /^https?:\/\//.test(url)
}
}
......
......@@ -33,18 +33,18 @@ export default {
components: { LazyWrapper },
computed: {
user() {
user () {
return this.$store.state.users[this.$route.params.id]
}
},
head() {
head () {
return {
title: this.user ? this.user.id : 'User not found'
}
},
fetch({ store, route: { params: { id } } }) {
fetch ({ store, route: { params: { id } } }) {
return store.dispatch('FETCH_USER', { id })
}
}
......
import Vue from 'vue'
export function host(url) {
export function host (url) {
const host = url.replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace('?id=', '/')
const parts = host.split('.').slice(-3)
if (parts[0] === 'www') parts.shift()
if (parts[0] === 'www') { parts.shift() }
return parts.join('.')
}
export function timeAgo(time) {
export function timeAgo (time) {
const between = Date.now() / 1000 - Number(time)
if (between < 3600) {
return pluralize(~~(between / 60), ' minute')
......@@ -18,7 +18,7 @@ export function timeAgo(time) {
}
}
function pluralize(time, label) {
function pluralize (time, label) {
if (time === 1) {
return time + label
}
......
import Vue from 'vue'
import { CancelToken } from 'axios'
import { validFeeds } from '~/common/api'
import { lazy } from '~/common/utils'
import { CancelToken } from 'axios'
// Learn more on https://nuxtjs.org/guide/vuex-store
......@@ -56,7 +56,7 @@ export const mutations = {
// Actions
// =================================================
export const actions = {
FETCH_FEED({ commit, state }, { feed, page, prefetch }) {
FETCH_FEED ({ commit, state }, { feed, page, prefetch }) {
// Don't priorotize already fetched feeds
if (state.feeds[feed][page] && state.feeds[feed][page].length) {
prefetch = true
......@@ -83,7 +83,7 @@ export const actions = {
)
},
FETCH_ITEM({ commit, state }, { id }) {
FETCH_ITEM ({ commit, state }, { id }) {
return lazy(
item => commit('SET_ITEM', { item }),
() => this.$axios.$get(`/item/${id}`),
......@@ -91,7 +91,7 @@ export const actions = {
)
},
FETCH_USER({ state, commit }, { id }) {
FETCH_USER ({ state, commit }, { id }) {
return lazy(
user => commit('SET_USER', { id, user }),
() => this.$axios.$get(`/user/${id}`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment