Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migration to nuxt3 #96

Merged
merged 53 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f3bf00e
feat: init migration to nuxt3
antfu Apr 18, 2022
207ae33
chore: update
antfu Apr 19, 2022
13254f4
chore: update
antfu Apr 19, 2022
6fa168d
chore: switch to nuxt eslint config
antfu Apr 19, 2022
ecca97d
chore: update ignore
antfu Apr 19, 2022
f7e4719
chore: update
antfu Apr 19, 2022
e160b93
chore: lint
antfu Apr 19, 2022
3a60a07
chore: cleanup
antfu Apr 19, 2022
8f05323
chore: clean up
antfu Apr 19, 2022
26bd583
chore: netlify config
antfu Apr 19, 2022
80e24e4
Update layouts/default.vue
antfu Apr 19, 2022
4b860a7
fix: avoid using `abortNavigation` for now
antfu Apr 19, 2022
53f013e
chore: cleanup
antfu Apr 19, 2022
85a225f
chore: migrate to `nuxt` package
antfu Apr 20, 2022
626f7d5
chore: cleanup
antfu Apr 20, 2022
fdd6c2c
chore: update docs
antfu Apr 20, 2022
176da43
chore: remove stylus
antfu Apr 20, 2022
6e46ed2
chore: update readme
antfu Apr 20, 2022
6a2c10d
Merge branch 'master' into nuxt3
antfu Apr 20, 2022
ee00722
chore: update
antfu Apr 20, 2022
9880e8a
chore: merge
antfu Apr 20, 2022
0035923
chore: update styling
antfu Apr 20, 2022
8b38d4d
chore: styling
antfu Apr 20, 2022
c760b74
chore: update
antfu Apr 21, 2022
d6f7753
feat: server api
antfu Apr 21, 2022
52414b1
feat: use server api
antfu Apr 21, 2022
e194283
fix: await for fetching on server side
antfu Apr 21, 2022
028dc26
chore: update spinner
antfu Apr 21, 2022
e7e33eb
refactor: clean up
antfu Apr 21, 2022
1593703
chore: move to dep deps
antfu Apr 21, 2022
dbd1fc8
chore: try workaround 404
antfu Apr 21, 2022
b9ed80d
chore: cleanup
antfu Apr 26, 2022
38eabb9
chore: update deps
antfu Apr 26, 2022
6f386ff
chore: remove deps on pinia
antfu Apr 27, 2022
249eb10
chore: use Pascal case
antfu Apr 27, 2022
6f5d6f3
chore: update lock
antfu Apr 27, 2022
18dde9a
chore: update
antfu Apr 27, 2022
f703758
chore: update
antfu Apr 27, 2022
2f66c98
fix: 404
antfu Apr 28, 2022
05dd671
chore: update performance
antfu Apr 28, 2022
013f7a1
chore: update deps
antfu May 8, 2022
c5f4bb8
chore: style
antfu May 9, 2022
dd13623
chore: update
antfu May 9, 2022
411e5ce
chore: fix lazyload on server side
antfu May 9, 2022
6de3e05
chore: remove transition
antfu May 9, 2022
a5fa7e3
feat: rework client fetch
antfu May 9, 2022
fb80ccb
chore: improve
antfu May 9, 2022
7e22ba7
chore: type
antfu May 11, 2022
83a4893
chore: use NuxtLink
antfu May 17, 2022
b586fb9
chore: update ogimage
antfu May 18, 2022
78c0257
chore: improve SEO
antfu May 18, 2022
7fd2b8b
Apply suggestions from code review
atinux May 24, 2022
b2548be
Update README.md
atinux May 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@nuxtjs/eslint-config-typescript",
"rules": {
"vue/no-v-html": "off"
}
}
5 changes: 0 additions & 5 deletions .eslintrc.js

This file was deleted.

7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ package-lock.json
*.iml
.nuxt
.vscode
.output

static/manifest*.json
static/sw.js
static/workbox-sw*.js*
public/manifest*.json
public/sw.js
public/workbox-sw*.js*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
3 changes: 0 additions & 3 deletions .vercelignore

This file was deleted.

8 changes: 0 additions & 8 deletions assets/logo.svg

This file was deleted.

19 changes: 0 additions & 19 deletions common/utils.js

This file was deleted.

43 changes: 20 additions & 23 deletions components/Comment.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<script setup lang="ts">
import { timeAgo } from '~/composables/utils'

defineProps({
comment: {
type: Object,
required: true
}
})

const open = ref(true)

function pluralize (n: number) {
return n + (n === 1 ? ' reply' : ' replies')
}
</script>

<template>
<li v-if="comment && comment.user" class="comment">
<div class="by">
<router-link :to="'/user/' + comment.user">
<RouterLink :to="'/user/' + comment.user">
antfu marked this conversation as resolved.
Show resolved Hide resolved
{{ comment.user }}
</router-link>
{{ comment.time | timeAgo }} ago
</RouterLink>
antfu marked this conversation as resolved.
Show resolved Hide resolved
{{ timeAgo(comment.time) }} ago
</div>
<div class="text" v-html="comment.content" />
<div v-if="comment.comments && comment.comments.length" :class="{ open }" class="toggle">
Expand All @@ -17,26 +34,6 @@
</li>
</template>

<script>
export default {
name: 'Comment',
props: {
comment: {
type: Object,
required: true
}
},
data () {
return {
open: true
}
},
methods: {
pluralize: n => n + (n === 1 ? ' reply' : ' replies')
}
}
</script>

<style lang="stylus">
.comment-children {
.comment-children {
Expand Down
35 changes: 13 additions & 22 deletions components/Item.vue
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
<script setup lang="ts">
import { timeAgo, isAbsolute } from '~/composables/utils'

defineProps<{
item: any
}>()
</script>

<template>
<li class="news-item">
<span class="score">{{ item.points }}</span>
<span class="title">
<template v-if="isAbsolute(item.url)">
<a :href="item.url" target="_blank" rel="noopener">{{ item.title }}</a>
<span class="host"> ({{ item.url | host }})</span>
<span class="host"> ({{ timeAgo(item.url) }})</span>
</template>
<template v-else>
<router-link :to="'/item/' + item.id">{{ item.title }}</router-link>
<RouterLink :to="'/item/' + item.id">{{ item.title }}</RouterLink>
antfu marked this conversation as resolved.
Show resolved Hide resolved
</template>
</span>
<br>
<span class="meta">
<span v-if="item.type !== 'job'" class="by">
by
<router-link :to="'/user/' + item.user">{{ item.user }}</router-link>
<RouterLink :to="'/user/' + item.user">{{ item.user }}</RouterLink>
antfu marked this conversation as resolved.
Show resolved Hide resolved
</span>
<span class="time">
{{ item.time | timeAgo }} ago
{{ timeAgo(item.time) }} ago
</span>
<span v-if="item.type !== 'job'" class="comments-link">
|
<router-link :to="'/item/' + item.id">{{ item.comments_count }} comments</router-link>
<RouterLink :to="'/item/' + item.id">{{ item.comments_count }} comments</RouterLink>
antfu marked this conversation as resolved.
Show resolved Hide resolved
</span>
</span>
</li>
</template>

<script>
export default {
name: 'NewsItem',
props: {
item: {
type: Object,
required: true
}
},
methods: {
isAbsolute (url) {
return /^https?:\/\//.test(url)
}
}
}
</script>

<style lang="stylus">
.news-item {
background-color: #fff;
Expand Down
42 changes: 14 additions & 28 deletions components/ItemListNav.vue
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
<script setup lang="ts">
const props = defineProps<{
feed: string,
page: number,
maxPage: number
}>()

const hasMore = $computed(() => props.page < props.maxPage)
</script>

<template>
<div class="news-list-nav">
<router-link v-if="page > 1" :to="`/${feed}/${page - 1}`">
<RouterLink v-if="page > 1" :to="`/${feed}/${page - 1}`">
antfu marked this conversation as resolved.
Show resolved Hide resolved
&lt; prev
</router-link>
</RouterLink>
antfu marked this conversation as resolved.
Show resolved Hide resolved
<a v-else class="disabled">&lt; prev</a>
atinux marked this conversation as resolved.
Show resolved Hide resolved
<span>{{ page }}/{{ maxPage }}</span>
<router-link v-if="hasMore" :to="`/${feed}/${page + 1}`">
<RouterLink v-if="hasMore" :to="`/${feed}/${page + 1}`">
antfu marked this conversation as resolved.
Show resolved Hide resolved
more &gt;
</router-link>
</RouterLink>
antfu marked this conversation as resolved.
Show resolved Hide resolved
<a v-else class="disabled">more &gt;</a>
atinux marked this conversation as resolved.
Show resolved Hide resolved
</div>
</template>

<script>
export default {
props: {
feed: {
type: String,
required: true
},
page: {
type: Number,
required: true
},
maxPage: {
type: Number,
required: true
}
},
computed: {
hasMore () {
return this.page < this.maxPage
}
}
}
</script>

<style lang="stylus">
.news-list-nav, .news-list {
background-color: #fff;
Expand Down
20 changes: 0 additions & 20 deletions components/LazyWrapper.vue

This file was deleted.

20 changes: 20 additions & 0 deletions components/LoadingWrapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineComponent, h } from 'vue'
import Spinner from './Spinner.vue'

export default defineComponent({
props: {
loading: {
type: Boolean,
default: false
}
},
setup (props, { slots }) {
return () => {
return props.loading
? h('div', { style: { 'text-align': 'center' } }, [
h(Spinner, { show: true })
])
: slots.default?.()
}
}
})
18 changes: 6 additions & 12 deletions components/Spinner.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script setup lang="ts">
defineProps<{
show: boolean
}>()
</script>

<template>
<transition>
<svg
Expand All @@ -21,18 +27,6 @@
</transition>
</template>

<script>
export default {
name: 'Spinner',
props: {
show: {
type: Boolean,
required: true
}
}
}
</script>

<style lang="stylus">
$offset = 126;
$duration = 1.4s;
Expand Down
4 changes: 2 additions & 2 deletions common/api.js → composables/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const feeds = {
export const feedsInfo = {
news: { title: 'News', pages: 10 },
newest: { title: 'Newest', pages: 12 },
ask: { title: 'Ask', pages: 2 },
show: { title: 'Show', pages: 2 },
jobs: { title: 'Jobs', pages: 1 }
}

export const validFeeds = Object.keys(feeds)
export const validFeeds = Object.keys(feedsInfo)
Loading