Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周韬
node-sample
Commits
1292128e
Commit
1292128e
authored
Jun 17, 2024
by
Sébastien Chopin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: no need for layouts
parent
54f871d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
171 deletions
+149
-171
README.md
README.md
+0
-2
app.vue
app/app.vue
+112
-8
AppHeader.vue
app/components/AppHeader.vue
+37
-161
No files found.
README.md
View file @
1292128e
...
...
@@ -19,8 +19,6 @@ https://hn.nuxt.dev
## Performance
-
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
...
...
app/app.vue
View file @
1292128e
<
script
setup
lang=
"ts"
>
useServerHead
({
htmlAttrs
:
{
lang
:
'en'
,
},
})
useSeoMeta
({
titleTemplate
:
'Nuxt HN | %s'
,
description
:
'HackerNews clone built with Nuxt.'
,
...
...
@@ -17,7 +12,116 @@ useSeoMeta({
</
script
>
<
template
>
<
NuxtLayout
>
<NuxtPage
/>
<
/NuxtLayout
>
<
Html
lang=
"en"
/
>
<AppHeader
/>
<
NuxtPage
/
>
</
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
>
app/
layouts/default
.vue
→
app/
components/AppHeader
.vue
View file @
1292128e
<
script
setup
lang=
"ts"
>
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
>
<
template
>
<div>
<header
class=
"header"
>
<nav
class=
"inner"
role=
"navigation"
<header
class=
"header"
>
<nav
class=
"inner"
role=
"navigation"
>
<NuxtLink
to=
"/"
aria-label=
"Go to homepage"
>
<NuxtLink
to=
"/"
aria-label=
"Go to homepage"
<svg
class=
"logo"
viewBox=
"0 0 900 900"
fill=
"none"
xmlns=
"http://www.w3.org/2000/svg"
>
<svg
class=
"logo"
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>
</NuxtLink>
<NuxtLink
v-for=
"(list, key) in feedsInfo"
:key=
"key"
:to=
"`/$
{key}`"
:class="{ active: $route.path.startsWith(`/${key}`) }"
<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>
</NuxtLink>
<NuxtLink
v-for=
"(list, key) in feedsInfo"
:key=
"key"
:to=
"`/$
{key}`"
:class="{ active: $route.path.startsWith(`/${key}`) }"
>
{{
list
.
title
}}
</NuxtLink>
<span
class=
"github"
>
<a
href=
"https://github.com/nuxt/hackernews"
target=
"_blank"
rel=
"noopener banner"
>
{{
list
.
title
}}
</NuxtLink>
<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"
/>
</div>
Open on GitHub
</a>
</span>
</nav>
</header>
</
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
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment