Commit 2c75b8cb authored by Sébastien Chopin's avatar Sébastien Chopin

feat: overall improvements

parent 79b245a0
# Nuxt3 Hacker News
# Nuxt Hacker News
Hacker News clone built with [Nuxt3](https://v3.nuxtjs.org).
Hacker News clone built with [Nuxt](https://nuxt.com).
<p align="center">
<a href="https://hn.nuxt.space" target="_blank">
<img width="1090" src="https://user-images.githubusercontent.com/904724/58875721-97382400-86cc-11e9-94c6-af21544817bb.png">
<img width="1090" src="https://hn.nuxt.space/cover.jpg">
<br>
Live Demo
</a>
......
<script setup lang="ts">
useHead({
useSeoMeta({
titleTemplate: 'Nuxt HN | %s',
meta: [
{ property: 'og:image', content: 'https://user-images.githubusercontent.com/11247099/169022756-cdb6ef6f-1299-4ce0-8f80-81fb6e86a2e1.png' },
{ name: 'description', content: 'Hacker News clone built with Nuxt 3' },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:site', content: '@nuxt_js' },
{ name: 'twitter:creator', content: '@nuxt_js' },
{ name: 'twitter:image', content: 'https://user-images.githubusercontent.com/11247099/169022756-cdb6ef6f-1299-4ce0-8f80-81fb6e86a2e1.png' }
],
description: 'HackerNews clone built with Nuxt.',
ogImage: 'https://hn.nuxt.space/cover.jpg',
ogImageAlt: 'Nuxt Hackernews',
twitterImage: 'https://hn.nuxt.space/cover.jpg',
twitterSite: '@nuxt_js',
twitterCreator: '@nuxt_js',
twitterCard: 'summary_large_image',
})
useHead({
link: [
{ rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }
]
......
......@@ -20,7 +20,7 @@ const hasMore = computed(() => props.page < props.maxPage)
v-else
class="disabled"
>&lt; prev</span>
<span class="page">{{ page }}/{{ maxPage }}</span>
<span class="page">{{ page }} / {{ maxPage }}</span>
<NuxtLink
v-if="hasMore"
:to="`/${feed}/${page + 1}`"
......@@ -37,13 +37,11 @@ const hasMore = computed(() => props.page < props.maxPage)
<style lang="postcss">
.news-list-nav, .news-list {
background-color: #fff;
border-radius: 2px;
}
.news-list-nav {
padding: 15px 30px;
text-align: center;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
user-select: none;
a {
......@@ -52,6 +50,7 @@ const hasMore = computed(() => props.page < props.maxPage)
.disabled {
opacity: 0.5;
margin: 0 1em;
}
.page {
......
<script setup lang="ts">
import { feedsInfo } from '~/composables/api'
const route = useRoute()
const host = process.server
? useRequestHeaders().host
......@@ -23,7 +21,6 @@ useHead({
>
<NuxtLink
to="/"
exact
>
<img
class="logo"
......@@ -35,17 +32,19 @@ useHead({
v-for="(list, key) in feedsInfo"
:key="key"
:to="`/${key}`"
:class="{ active: $route.path.startsWith(`/${key}`)}"
>
{{ list.title }}
</NuxtLink>
<a
class="github"
href="https://github.com/nuxt/hackernews"
target="_blank"
rel="noopener banner"
>
Built with Nuxt3
</a>
<span class="github">
<a
href="https://github.com/nuxt/hackernews"
target="_blank"
rel="noopener banner"
>
Open on GitHub
</a>
</span>
</nav>
</header>
<slot role="main" />
......@@ -56,20 +55,19 @@ useHead({
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
background-color: lighten(#eceef1, 30%);
background-color: #F4F4F5;
margin: 0;
padding: 0;
color: #2E495E;
color: #18181B;
overflow-y: scroll;
}
a {
color: #2E495E;
color: #18181B;
text-decoration: none;
}
.header {
background-color: #2E495E;
background-color: #18181B;
z-index: 999;
height: 55px;
......@@ -93,12 +91,11 @@ a {
margin-right: 1.8em;
&:hover {
color: #fff;
color: #00DC82;
}
&.router-link-active, &.nuxt-link-active {
color: #fff;
font-weight: 600;
&.active {
color: #00DC82;
}
&:nth-child(6) {
......@@ -112,6 +109,9 @@ a {
margin: auto;
text-align: right;
flex-grow: 1;
a {
margin-right: 0;
}
}
}
......
export default defineNuxtRouteMiddleware((from) => {
if (from.path === '/') {
return navigateTo(`/${validFeeds[0]}/1`)
}
})
<script setup lang="ts">
import { feedsInfo } from '~/composables/api'
definePageMeta({
middleware: 'feed'
})
......
<script setup lang="ts">
definePageMeta({
middleware: 'index'
middleware: (from) => {
if (from.path === '/') {
return navigateTo(`/${validFeeds[0]}/1`)
}
}
})
</script>
......
<script setup lang="ts">
import { host, timeAgo, isAbsolute } from '~/composables/utils'
const route = useRoute()
const id = computed(() => +route.params.id)
......
<script setup lang="ts">
import { timeAgo } from '~/composables/utils'
const route = useRoute()
const id = computed(() => route.params.id as string)
......
......@@ -4156,7 +4156,7 @@ packages:
dependencies:
acorn: 8.8.2
pathe: 1.1.0
pkg-types: 1.0.1
pkg-types: 1.0.2
ufo: 1.1.1
dev: true
......@@ -4612,14 +4612,6 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/pkg-types/1.0.1:
resolution: {integrity: sha512-jHv9HB+Ho7dj6ItwppRDDl0iZRYBD0jsakHXtFgoLr+cHSF6xC+QL54sJmWxyGxOLYSHm0afhXhXcQDQqH9z8g==}
dependencies:
jsonc-parser: 3.2.0
mlly: 1.1.1
pathe: 1.1.0
dev: true
/pkg-types/1.0.2:
resolution: {integrity: sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==}
dependencies:
......@@ -5678,7 +5670,7 @@ packages:
magic-string: 0.27.0
mlly: 1.1.1
pathe: 1.1.0
pkg-types: 1.0.1
pkg-types: 1.0.2
scule: 1.0.0
strip-literal: 1.0.1
unplugin: 1.1.0
......@@ -5696,7 +5688,7 @@ packages:
magic-string: 0.27.0
mlly: 1.1.1
pathe: 1.1.0
pkg-types: 1.0.1
pkg-types: 1.0.2
scule: 1.0.0
strip-literal: 1.0.1
unplugin: 1.1.0
......
<svg xmlns="http://www.w3.org/2000/svg" width="48.77" height="32" viewBox="0 0 256 168"><path fill="#00DC82" d="M143.618 167.029h95.166c3.023 0 5.992-.771 8.61-2.237a16.963 16.963 0 0 0 6.302-6.115a16.324 16.324 0 0 0 2.304-8.352c0-2.932-.799-5.811-2.312-8.35L189.778 34.6a16.966 16.966 0 0 0-6.301-6.113a17.626 17.626 0 0 0-8.608-2.238c-3.023 0-5.991.772-8.609 2.238a16.964 16.964 0 0 0-6.3 6.113l-16.342 27.473l-31.95-53.724a16.973 16.973 0 0 0-6.304-6.112A17.638 17.638 0 0 0 96.754 0c-3.022 0-5.992.772-8.61 2.237a16.973 16.973 0 0 0-6.303 6.112L2.31 141.975a16.302 16.302 0 0 0-2.31 8.35c0 2.932.793 5.813 2.304 8.352a16.964 16.964 0 0 0 6.302 6.115a17.628 17.628 0 0 0 8.61 2.237h59.737c23.669 0 41.123-10.084 53.134-29.758l29.159-48.983l15.618-26.215l46.874 78.742h-62.492l-15.628 26.214Zm-67.64-26.24l-41.688-.01L96.782 35.796l31.181 52.492l-20.877 35.084c-7.976 12.765-17.037 17.416-31.107 17.416Z"/></svg>
<svg width="900" height="900" viewBox="0 0 900 900" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M504.908 750H839.476C850.103 750.001 860.542 747.229 869.745 741.963C878.948 736.696 886.589 729.121 891.9 719.999C897.211 710.876 900.005 700.529 900 689.997C899.995 679.465 897.193 669.12 891.873 660.002L667.187 274.289C661.876 265.169 654.237 257.595 645.036 252.329C635.835 247.064 625.398 244.291 614.773 244.291C604.149 244.291 593.711 247.064 584.511 252.329C575.31 257.595 567.67 265.169 562.36 274.289L504.908 372.979L392.581 179.993C387.266 170.874 379.623 163.301 370.42 158.036C361.216 152.772 350.777 150 340.151 150C329.525 150 319.086 152.772 309.883 158.036C300.679 163.301 293.036 170.874 287.721 179.993L8.12649 660.002C2.80743 669.12 0.00462935 679.465 5.72978e-06 689.997C-0.00461789 700.529 2.78909 710.876 8.10015 719.999C13.4112 729.121 21.0523 736.696 30.255 741.963C39.4576 747.229 49.8973 750.001 60.524 750H270.538C353.748 750 415.112 713.775 457.336 643.101L559.849 467.145L614.757 372.979L779.547 655.834H559.849L504.908 750ZM267.114 655.737L120.551 655.704L340.249 278.586L449.87 467.145L376.474 593.175C348.433 639.03 316.577 655.737 267.114 655.737Z" fill="#00DC82"/>
</svg>
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