Added basic login.
This commit is contained in:
43
pages/users/@username/+Page.vue
Normal file
43
pages/users/@username/+Page.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<div class="profile">
|
||||
<div class="profile-header">
|
||||
<img
|
||||
v-if="profile.avatar"
|
||||
:src="profile.avatar"
|
||||
class="avatar"
|
||||
>
|
||||
|
||||
<h2 class="username">{{ profile.username }}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
const profile = pageContext.pageProps.profile;
|
||||
|
||||
console.log('profile', profile);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.profile-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: .5rem 1rem;
|
||||
color: var(--highlight-strong-30);
|
||||
background: var(--grey-dark-40);
|
||||
}
|
||||
|
||||
.username {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: .25rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
</style>
|
||||
14
pages/users/@username/+onBeforeRender.js
Normal file
14
pages/users/@username/+onBeforeRender.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { fetchUser } from '#/src/users.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
const profile = await fetchUser(pageContext.routeParams.username);
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: profile.username,
|
||||
pageProps: {
|
||||
profile, // differentiate from authed 'user'
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
1
pages/users/@username/+route.js
Normal file
1
pages/users/@username/+route.js
Normal file
@@ -0,0 +1 @@
|
||||
export default '/user/@username';
|
||||
Reference in New Issue
Block a user