Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nandomoreirame committed Dec 18, 2019
2 parents 6331f5e + 2d96245 commit e3735fa
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 3,518 deletions.
5 changes: 5 additions & 0 deletions .nowignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
.vscode
.nuxt
.editorconfig
.eslintrc.js
17 changes: 13 additions & 4 deletions components/phrase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ export default {
})
},
methods: {
changeQuote () {
const phraseId = Math.floor(Math.random() * this.phrases.length)
const phrase = this.phrases[phraseId]
this.$router.push(`/${phraseId}/${slugAuthor(phrase.author)}`)
async changeQuote () {
let phrases = this.phrases
this.$store.commit('toggleLoading', true)
if (!phrases.length) {
phrases = await this.$axios.$get('/phrases')
this.$store.commit('changePhrases', phrases)
}
const radomPhraseId = Math.floor(Math.random() * phrases.length)
const phrase = phrases[radomPhraseId]
return this.$router.push(`/${radomPhraseId}/${slugAuthor(phrase.author)}`)
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions netlify.toml

This file was deleted.

12 changes: 12 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 2,
"public": true,
"name": "motivaai-nuxt",
"builds": [
{
"src": "nuxt.config.js",
"use": "@nuxtjs/now-builder",
"config": {}
}
]
}
19 changes: 5 additions & 14 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import axios from 'axios'
import { slugAuthor } from './utils'

const baseURL = 'https://api-motivaai.nandomoreira.dev'
const siteUrl = `https://motivaai.nandomoreira.me`
const title = `💪🏼 Motiva Aí`
const description = process.env.npm_package_description
const baseURL = 'https://api-motivaai.nandomoreira.dev/v1'
const siteUrl = `https://motivaai.nandomoreira.dev`

export default {
mode: 'universal',
Expand All @@ -14,14 +11,7 @@ export default {
description
},
generate: {
fallback: true,
routes () {
axios.defaults.baseURL = baseURL
return axios.get(`v1`)
.then(({ data }) =>
data.data.map((phrase, id) =>
`/${id}/${slugAuthor(phrase.author)}`))
}
fallback: true
},
head: {
htmlAttrs: {
Expand Down Expand Up @@ -58,14 +48,15 @@ export default {
]
},
loading: false,
// plugins: ['~/plugins/axios'],
server: {
port: process.env.PORT || 3000,
host: '0.0.0.0'
},
buildModules: [
'@nuxtjs/eslint-module',
['@nuxtjs/google-analytics', {
id: process.env.GOOGLE_ANALYTICS || 'UA-000000000-1'
id: process.env.google_analytics || 'UA-000000000-1'
}]
],
modules: [
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "motivaai",
"version": "2.3.0",
"version": "2.4.0",
"description": "💪 Gere uma frase motivacional pra dar um UP no seu dia!",
"author": "Fernando Moreira",
"private": true,
"engines": {
"node": ">=10"
},
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"deploy": "npm run build && npm run generate && netlify deploy",
"release": "npm run deploy -- --prod",
"deploy": "now",
"release": "now --prod",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
"dependencies": {
Expand All @@ -27,7 +30,6 @@
"@nuxtjs/eslint-module": "^1.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^6.1.0",
"eslint-plugin-nuxt": ">=0.4.2",
"netlify-cli": "^2.25.0"
"eslint-plugin-nuxt": ">=0.4.2"
}
}
23 changes: 8 additions & 15 deletions pages/_id/_author.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</template>

<script>
import { mapState } from 'vuex'
import { randonBackground } from '@/utils'
export default {
Expand All @@ -20,33 +19,27 @@ export default {
Phrase: () => import('@/components/phrase.vue'),
SEO: () => import('@/components/seo.vue')
},
computed: {
...mapState({
phrase: ({ phrase }) => phrase
})
},
async asyncData ({ $axios, store, params }) {
const { id } = params
const { phrases } = store.state
let { phrase } = store.state
store.commit('toggleLoading', true)
store.commit('changeBackground', randonBackground())
if (phrases.length > 0) {
if (Object.keys(phrase).length && phrase.id === id) {
store.commit('toggleLoading', false)
store.commit('changePhrase', phrases[id])
return { data: phrases }
store.commit('changePhrase', phrase)
return { phrase }
}
const { data } = await $axios.$get('/v1')
phrase = await $axios.$get(`/phrase/${id}`)
if (data.length > 0) {
if (Object.keys(phrase).length) {
store.commit('toggleLoading', false)
store.commit('changePhrase', data[id])
store.commit('changePhrases', data)
store.commit('changePhrase', phrase)
}
return { data }
return { phrase }
}
}
</script>
4 changes: 2 additions & 2 deletions pages/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default {
store.commit('toggleLoading', false)
phrase = phrases[id]
} else {
phrase = await $axios.$get('/v1')
.then(({ data }) => {
phrase = await $axios.$get('/phrases')
.then((data) => {
store.commit('toggleLoading', false)
store.commit('changePhrases', data)
store.commit('changePhrase', data[id])
Expand Down
2 changes: 1 addition & 1 deletion pages/frases.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
return { data: phrases }
}
const { data } = await $axios.$get('/v1')
const data = await $axios.$get('/phrases')
if (data.length > 0) {
store.commit('toggleLoading', false)
Expand Down
28 changes: 9 additions & 19 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,32 @@
</template>

<script>
import { mapState } from 'vuex'
import { randonPhrase, randonBackground } from '@/utils'
import { randonBackground } from '@/utils'
export default {
name: 'Home',
components: {
Phrase: () => import('@/components/phrase.vue'),
SEO: () => import('@/components/seo.vue')
},
computed: {
...mapState({
phrase: ({ phrase }) => phrase
})
},
async asyncData ({ $axios, store }) {
store.commit('toggleLoading', true)
store.commit('changeBackground', randonBackground())
let { phrases } = store.state
const { phrases } = store.state
if (phrases.length > 0) {
store.commit('toggleLoading', false)
store.commit('changePhrase', randonPhrase(phrases)[0])
if (!phrases.length) {
phrases = await $axios.$get('/phrases')
store.commit('changePhrases', phrases)
return { data: phrases }
}
const { data } = await $axios.$get('/v1')
const radomPhraseId = Math.floor(Math.random() * phrases.length)
const phrase = phrases[radomPhraseId]
if (data.length > 0) {
if (Object.keys(phrase).length) {
store.commit('toggleLoading', false)
store.commit('changePhrase', randonPhrase(data)[0])
store.commit('changePhrases', data)
store.commit('changePhrase', phrase)
return { phrase }
}
return { data }
}
}
</script>
17 changes: 17 additions & 0 deletions plugins/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default function ({ $axios, redirect }) {
$axios.onRequest((req) => {
console.log('onRequest...')
console.log(req)
})

$axios.onResponse(({ data }) => {
console.log('onResponse...')
console.log(data)
})

$axios.onError((error) => {
if (error.response.status === 500) {
redirect('/500')
}
})
}
8 changes: 4 additions & 4 deletions static/_redirects
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Redirect default Netlify subdomain to primary domain
http://motivaai.netlify.com/* https://motivaai.nandomoreira.me/:splat 301!
http://motivaai.nandomoreira.me/* https://motivaai.nandomoreira.me/:splat 301!

/* /index.html 200
http://motivaai.netlify.com/* https://motivaai.nandomoreira.dev/:splat 301!
https://motivaai.netlify.com/* https://motivaai.nandomoreira.dev/:splat 301!
http://motivaai.nandomoreira.me/* https://motivaai.nandomoreira.dev/:splat 301!
https://motivaai.nandomoreira.me/* https://motivaai.nandomoreira.dev/:splat 301!
Binary file modified static/favicon.ico
Binary file not shown.
14 changes: 7 additions & 7 deletions static/humans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
Email: nandomoreira.me [at] gmail.com
From: Curitiba, Paraná, Brazil

/* SITE */
Language: Portuguese
Doctype: HTML5
IDE: Visual Studio Code, Sketch
Tech stack: Nuxt, Vuejs, ECMAScript, HTML5, CSS3

/* THANKS */
Developer: Gilberto Domingues
Github: https://github.com/GIlbertoDomingues
Email: giba.front [at] gmail.com
From: Curitiba, Paraná, Brazil

/* THANKS */
Developer: Felipe Pontes
Twitter: @felipemfp
Site: https://felipemfp.github.io/
Github: https://github.com/felipemfp
From: Natal, Rio Grande do Norte, Brazil

/* SITE */
Language: Portuguese
Doctype: HTML5
IDE: Visual Studio Code, Sketch
Tech stack: Nuxt, Vuejs, JavaScript, HTML5, CSS3
Binary file modified static/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

1 comment on commit e3735fa

@vercel
Copy link

@vercel vercel bot commented on e3735fa Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to alias the deployment: Deployment not found.

Click here to access the non-aliased deployment.

Please sign in to comment.