iamseeley-multiroutevue.web.val.run
Readme

🌐 Multi-Route Website with Vue

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* @title Multi-Route Website with Vue in Val Town
* @description Create a personal portfolio website with multiple pages using Vue 3 and server-side rendering.
*/
import { createSSRApp, h } from 'npm:vue@3';
import { renderToString } from 'npm:vue/server-renderer';
import { websiteStyles } from "https://esm.town/v/iamseeley/websiteStyles";
import { personalData } from "https://esm.town/v/iamseeley/personalData";
// Navigation component
const Navigation = {
props: ['currentPath'],
setup(props) {
const links = [
{ path: '/', text: 'Home' },
{ path: '/about', text: 'About' },
{ path: '/projects', text: 'Projects' }
];
return () => h('nav', {}, links.map(link =>
h('a', {
href: link.path,
class: props.currentPath === link.path ? 'active' : ''
}, link.text)
));
}
};
// Footer component
const Footer = {
setup() {
return () => h('footer', {}, [
h('ul', {}, personalData.profiles.map((profile, index) =>
h('li', { key: index }, [
h('a', { href: profile.url, target: '_blank', rel: 'noopener noreferrer' }, profile.network)
])
))
]);
}
};
// Page components
const HomePage = {
setup() {
return () => h('div', {}, [
h(Navigation, { currentPath: '/' }),
h('main', {}, [
h('h2', {}, 'Welcome to My Portfolio'),
h('p', {}, personalData.summary),
h('p', {}, [
h('strong', {}, 'This website is rendered server-side with Vue.')
]),
h('p', {}, [
'Check out the ',
h('a', { href: 'https://www.val.town/v/iamseeley/multirouteVue', target: '_blank', rel: 'noopener noreferrer' }, 'source'),
' and start building your own site!'
])
]),
h(Footer)
]);
}
};
const AboutPage = {
setup() {
return () => h('div', {}, [
h(Navigation, { currentPath: '/about' }),
h('main', {}, [
h('h2', {}, 'About Me'),
h('p', {}, personalData.about)
]),
h(Footer)
]);
}
};
const ProjectsPage = {
setup() {
return () => h('div', {}, [
h(Navigation, { currentPath: '/projects' }),
h('main', {}, [
h('h2', {}, 'My Projects'),
...personalData.projects.map(project =>
h('a', { href: project.url, target: '_blank', class: 'projectLink' }, [
h('div', { class: 'project' }, [
h('h3', {}, project.name),
h('p', {}, project.description)
])
])
)
]),
h(Footer)
]);
}
};
const NotFoundPage = {
setup() {
return () => h('div', {}, [
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 25, 2024