Commit 1292128e authored by Sébastien Chopin's avatar Sébastien Chopin

chore: no need for layouts

parent 54f871d7
...@@ -19,8 +19,6 @@ https://hn.nuxt.dev ...@@ -19,8 +19,6 @@ https://hn.nuxt.dev
## Performance ## Performance
- Lighthouse [100/100](https://pagespeed.web.dev/report?url=https%3A%2F%2Fhn.nuxt.dev%2Fnews%2F1) (Slow 4G / Mobile Moto G4) - Lighthouse [100/100](https://pagespeed.web.dev/report?url=https%3A%2F%2Fhn.nuxt.dev%2Fnews%2F1) (Slow 4G / Mobile Moto G4)
- Interactive: 1.4s
- Total Blocking Time: 30ms
## Features ## Features
......
<script setup lang="ts"> <script setup lang="ts">
useServerHead({
htmlAttrs: {
lang: 'en',
},
})
useSeoMeta({ useSeoMeta({
titleTemplate: 'Nuxt HN | %s', titleTemplate: 'Nuxt HN | %s',
description: 'HackerNews clone built with Nuxt.', description: 'HackerNews clone built with Nuxt.',
...@@ -17,7 +12,116 @@ useSeoMeta({ ...@@ -17,7 +12,116 @@ useSeoMeta({
</script> </script>
<template> <template>
<NuxtLayout> <Html lang="en" />
<NuxtPage /> <AppHeader />
</NuxtLayout> <NuxtPage />
</template> </template>
<style lang="postcss">
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: #F4F4F5;
margin: 0;
padding: 0;
color: #020420;
overflow-y: scroll;
}
a {
color: #020420;
text-decoration: none;
}
.header {
background-color: #020420;
z-index: 999;
height: 55px;
.inner {
max-width: 800px;
box-sizing: border-box;
margin: 0px auto;
padding: 12px 5px;
display: flex;
place-items: center;
}
& a {
color: #fff;
line-height: 24px;
transition: color 0.15s ease;
display: inline-block;
vertical-align: middle;
font-weight: 300;
letter-spacing: 0.075em;
margin-right: 1.8em;
&:hover {
color: #00DC82;
}
&.active {
color: #00DC82;
}
&:nth-child(6) {
margin-right: 0;
}
}
.github {
color: #fff;
font-size: 0.9em;
margin: auto;
text-align: right;
flex-grow: 1;
& a {
margin-right: 0;
}
}
}
.logo {
width: 30px;
height: 30px;
margin-right: 10px;
display: inline-block;
vertical-align: middle;
}
.view {
max-width: 800px;
margin: 0 auto;
position: relative;
}
.appear-active {
transition: opacity 0.4s ease;
}
.appear {
opacity: 0;
}
@media (max-width: 860px) {
.header .inner {
padding: 15px 30px;
}
}
@media (max-width: 600px) {
.header {
.inner {
padding: 15px;
}
& a {
margin-right: 1em;
}
.github {
display: none;
}
}
}
</style>
<script setup lang="ts"> <script setup lang="ts">
import { feedsInfo } from '~~/utils/api' import { feedsInfo } from '~~/utils/api'
const route = useRoute()
const host = import.meta.server
? useRequestHeaders().host
: window.location.host
useHead({
link: [
// We use route.path since we don't use query parameters
{ rel: 'canonical', href: `https://${host}${route.path}` },
],
})
</script> </script>
<template> <template>
<div> <header class="header">
<header class="header"> <nav
<nav class="inner"
class="inner" role="navigation"
role="navigation" >
<NuxtLink
to="/"
aria-label="Go to homepage"
> >
<NuxtLink <svg
to="/" class="logo"
aria-label="Go to homepage" viewBox="0 0 900 900"
fill="none"
xmlns="http://www.w3.org/2000/svg"
> >
<svg <path
class="logo" 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"
viewBox="0 0 900 900" fill="#00DC82"
fill="none" />
xmlns="http://www.w3.org/2000/svg" </svg>
> </NuxtLink>
<path <NuxtLink
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" v-for="(list, key) in feedsInfo"
fill="#00DC82" :key="key"
/> :to="`/${key}`"
</svg> :class="{ active: $route.path.startsWith(`/${key}`) }"
</NuxtLink> >
<NuxtLink {{ list.title }}
v-for="(list, key) in feedsInfo" </NuxtLink>
:key="key" <span class="github">
:to="`/${key}`" <a
:class="{ active: $route.path.startsWith(`/${key}`) }" href="https://github.com/nuxt/hackernews"
target="_blank"
rel="noopener banner"
> >
{{ list.title }} Open on GitHub
</NuxtLink> </a>
<span class="github"> </span>
<a </nav>
href="https://github.com/nuxt/hackernews" </header>
target="_blank"
rel="noopener banner"
>
Open on GitHub
</a>
</span>
</nav>
</header>
<slot role="main" />
</div>
</template> </template>
<style lang="postcss">
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: #F4F4F5;
margin: 0;
padding: 0;
color: #020420;
overflow-y: scroll;
}
a {
color: #020420;
text-decoration: none;
}
.header {
background-color: #020420;
z-index: 999;
height: 55px;
.inner {
max-width: 800px;
box-sizing: border-box;
margin: 0px auto;
padding: 12px 5px;
display: flex;
place-items: center;
}
& a {
color: #fff;
line-height: 24px;
transition: color 0.15s ease;
display: inline-block;
vertical-align: middle;
font-weight: 300;
letter-spacing: 0.075em;
margin-right: 1.8em;
&:hover {
color: #00DC82;
}
&.active {
color: #00DC82;
}
&:nth-child(6) {
margin-right: 0;
}
}
.github {
color: #fff;
font-size: 0.9em;
margin: auto;
text-align: right;
flex-grow: 1;
& a {
margin-right: 0;
}
}
}
.logo {
width: 30px;
height: 30px;
margin-right: 10px;
display: inline-block;
vertical-align: middle;
}
.view {
max-width: 800px;
margin: 0 auto;
position: relative;
}
.appear-active {
transition: opacity 0.4s ease;
}
.appear {
opacity: 0;
}
@media (max-width: 860px) {
.header .inner {
padding: 15px 30px;
}
}
@media (max-width: 600px) {
.header {
.inner {
padding: 15px;
}
& a {
margin-right: 1em;
}
.github {
display: none;
}
}
}
</style>
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