first commit
This commit is contained in:
97
templates/portfolio-cloudflare/src/pages/404.astro
Normal file
97
templates/portfolio-cloudflare/src/pages/404.astro
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
import Base from "../layouts/Base.astro";
|
||||
---
|
||||
|
||||
<Base title="Page not found">
|
||||
<div class="not-found">
|
||||
<span class="not-found-code">404</span>
|
||||
<h1>Page not found</h1>
|
||||
<p>The page you're looking for doesn't exist or has been moved.</p>
|
||||
<div class="not-found-links">
|
||||
<a href="/" class="link-primary">Go home</a>
|
||||
<a href="/work" class="link-secondary">View our work</a>
|
||||
</div>
|
||||
</div>
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.not-found {
|
||||
text-align: center;
|
||||
padding: var(--spacing-4xl) var(--spacing-lg);
|
||||
max-width: var(--max-width);
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.not-found-code {
|
||||
display: block;
|
||||
font-family: var(--font-serif);
|
||||
font-size: 8rem;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
color: var(--color-border);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.not-found h1 {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-2xl);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.not-found p {
|
||||
color: var(--color-muted);
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.not-found-links {
|
||||
display: flex;
|
||||
gap: var(--spacing-md);
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.link-primary {
|
||||
padding: var(--spacing-sm) var(--spacing-lg);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-bg);
|
||||
background: var(--color-text);
|
||||
text-decoration: none;
|
||||
border-radius: var(--radius);
|
||||
transition:
|
||||
background var(--transition-fast),
|
||||
transform var(--transition-fast);
|
||||
}
|
||||
|
||||
.link-primary:hover {
|
||||
background: var(--color-accent);
|
||||
color: white;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.link-secondary {
|
||||
padding: var(--spacing-sm) var(--spacing-lg);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
transition:
|
||||
border-color var(--transition-fast),
|
||||
transform var(--transition-fast);
|
||||
}
|
||||
|
||||
.link-secondary:hover {
|
||||
border-color: var(--color-text);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.not-found-code {
|
||||
font-size: 5rem;
|
||||
}
|
||||
|
||||
.not-found-links {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
174
templates/portfolio-cloudflare/src/pages/about.astro
Normal file
174
templates/portfolio-cloudflare/src/pages/about.astro
Normal file
@@ -0,0 +1,174 @@
|
||||
---
|
||||
import { getEmDashEntry } from "emdash";
|
||||
import { PortableText } from "emdash/ui";
|
||||
import Base from "../layouts/Base.astro";
|
||||
|
||||
const { entry: page, cacheHint } = await getEmDashEntry("pages", "about");
|
||||
|
||||
try {
|
||||
Astro.cache.set(cacheHint);
|
||||
} catch {}
|
||||
---
|
||||
|
||||
<Base title="About" description="Learn more about who we are and what we do.">
|
||||
<div class="about-page">
|
||||
<header class="about-header">
|
||||
<h1 class="about-title" {...page?.edit?.title}>
|
||||
{page?.data?.title || "About"}
|
||||
</h1>
|
||||
</header>
|
||||
|
||||
<div class="about-content" {...page?.edit?.content}>
|
||||
{
|
||||
page?.data?.content ? (
|
||||
<PortableText value={page.data.content} />
|
||||
) : (
|
||||
<p>Content coming soon.</p>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
|
||||
<aside class="about-sidebar">
|
||||
<div class="sidebar-section">
|
||||
<h3>Services</h3>
|
||||
<ul>
|
||||
<li>Brand Identity</li>
|
||||
<li>Web Design & Development</li>
|
||||
<li>Print Design</li>
|
||||
<li>Photography & Art Direction</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-section">
|
||||
<h3>Contact</h3>
|
||||
<p>
|
||||
<a href="mailto:hello@studio.example">hello@studio.example</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="/contact">Send us a message →</a>
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.about-page {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-2xl) var(--spacing-lg) var(--spacing-4xl);
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
grid-template-rows: auto 1fr;
|
||||
gap: var(--spacing-4xl);
|
||||
}
|
||||
|
||||
.about-header {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.about-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-4xl);
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.about-content {
|
||||
font-size: var(--font-size-base);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.about-content :global(p) {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
.about-content :global(h2) {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-2xl);
|
||||
font-weight: 500;
|
||||
margin-top: 2.5em;
|
||||
margin-bottom: 0.75em;
|
||||
}
|
||||
|
||||
.about-content :global(h3) {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 500;
|
||||
margin-top: 2em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.about-sidebar {
|
||||
position: sticky;
|
||||
top: var(--spacing-xl);
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
.sidebar-section {
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.sidebar-section h3 {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.sidebar-section ul {
|
||||
list-style: none;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
.sidebar-section li {
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.sidebar-section p {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.sidebar-section a {
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
.sidebar-section a:hover {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.about-page {
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.about-title {
|
||||
font-size: var(--font-size-3xl);
|
||||
}
|
||||
|
||||
.about-sidebar {
|
||||
position: static;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--spacing-xl);
|
||||
padding-top: var(--spacing-xl);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.sidebar-section {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.about-sidebar {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
357
templates/portfolio-cloudflare/src/pages/contact.astro
Normal file
357
templates/portfolio-cloudflare/src/pages/contact.astro
Normal file
@@ -0,0 +1,357 @@
|
||||
---
|
||||
import Base from "../layouts/Base.astro";
|
||||
|
||||
// Handle form submission
|
||||
let formStatus: "idle" | "success" | "error" = "idle";
|
||||
let formMessage = "";
|
||||
|
||||
if (Astro.request.method === "POST") {
|
||||
try {
|
||||
const formData = await Astro.request.formData();
|
||||
const name = formData.get("name")?.toString() || "";
|
||||
const email = formData.get("email")?.toString() || "";
|
||||
const message = formData.get("message")?.toString() || "";
|
||||
|
||||
// Basic validation
|
||||
if (!name || !email || !message) {
|
||||
formStatus = "error";
|
||||
formMessage = "Please fill in all fields.";
|
||||
} else if (!email.includes("@")) {
|
||||
formStatus = "error";
|
||||
formMessage = "Please enter a valid email address.";
|
||||
} else {
|
||||
// In a real implementation, you would send this to an email service,
|
||||
// save to database, or forward to a webhook.
|
||||
// For this template, we just show a success message.
|
||||
console.log("Contact form submission:", { name, email, message });
|
||||
formStatus = "success";
|
||||
formMessage = "Thanks for reaching out! We'll get back to you soon.";
|
||||
}
|
||||
} catch {
|
||||
formStatus = "error";
|
||||
formMessage = "Something went wrong. Please try again.";
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
<Base title="Contact" description="Get in touch with us about your next project.">
|
||||
<div class="contact-page">
|
||||
<header class="contact-header">
|
||||
<h1 class="contact-title">Get in Touch</h1>
|
||||
<p class="contact-intro">
|
||||
Have a project in mind? We'd love to hear about it. Fill out the form below
|
||||
and we'll get back to you within 24 hours.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div class="contact-grid">
|
||||
<div class="contact-form-wrapper">
|
||||
{formStatus === "success" ? (
|
||||
<div class="form-success">
|
||||
<h2>Message Sent</h2>
|
||||
<p>{formMessage}</p>
|
||||
<a href="/contact" class="form-reset">Send another message</a>
|
||||
</div>
|
||||
) : (
|
||||
<form method="POST" class="contact-form">
|
||||
{formStatus === "error" && (
|
||||
<div class="form-error">
|
||||
<p>{formMessage}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div class="form-field">
|
||||
<label for="name">Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="name"
|
||||
name="name"
|
||||
required
|
||||
placeholder="Your name"
|
||||
autocomplete="name"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="email">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
required
|
||||
placeholder="you@example.com"
|
||||
autocomplete="email"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="message">Message</label>
|
||||
<textarea
|
||||
id="message"
|
||||
name="message"
|
||||
required
|
||||
rows="6"
|
||||
placeholder="Tell us about your project..."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="form-submit">
|
||||
Send Message
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<aside class="contact-info">
|
||||
<div class="info-section">
|
||||
<h3>Email</h3>
|
||||
<p>
|
||||
<a href="mailto:hello@studio.example">hello@studio.example</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<h3>Location</h3>
|
||||
<p>San Francisco, CA</p>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<h3>Social</h3>
|
||||
<ul class="social-links">
|
||||
<li><a href="https://twitter.com" target="_blank" rel="noopener noreferrer">Twitter</a></li>
|
||||
<li><a href="https://instagram.com" target="_blank" rel="noopener noreferrer">Instagram</a></li>
|
||||
<li><a href="https://dribbble.com" target="_blank" rel="noopener noreferrer">Dribbble</a></li>
|
||||
<li><a href="https://linkedin.com" target="_blank" rel="noopener noreferrer">LinkedIn</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.contact-page {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-2xl) var(--spacing-lg) var(--spacing-4xl);
|
||||
}
|
||||
|
||||
.contact-header {
|
||||
max-width: var(--max-width);
|
||||
margin-bottom: var(--spacing-3xl);
|
||||
}
|
||||
|
||||
.contact-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-4xl);
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.contact-intro {
|
||||
font-size: var(--font-size-lg);
|
||||
color: var(--color-muted);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.contact-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
gap: var(--spacing-4xl);
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.form-field label {
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.form-field input,
|
||||
.form-field textarea {
|
||||
padding: var(--spacing-md);
|
||||
font-family: inherit;
|
||||
font-size: var(--font-size-base);
|
||||
color: var(--color-text);
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
transition:
|
||||
border-color var(--transition-fast),
|
||||
box-shadow var(--transition-fast);
|
||||
}
|
||||
|
||||
.form-field input:focus,
|
||||
.form-field textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-accent);
|
||||
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
|
||||
}
|
||||
|
||||
.form-field input::placeholder,
|
||||
.form-field textarea::placeholder {
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
.form-field textarea {
|
||||
resize: vertical;
|
||||
min-height: 150px;
|
||||
}
|
||||
|
||||
.form-submit {
|
||||
align-self: flex-start;
|
||||
padding: var(--spacing-md) var(--spacing-xl);
|
||||
font-family: inherit;
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
color: var(--color-bg);
|
||||
background: var(--color-text);
|
||||
border: none;
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background var(--transition-fast),
|
||||
transform var(--transition-fast);
|
||||
}
|
||||
|
||||
.form-submit:hover {
|
||||
background: var(--color-accent);
|
||||
color: white;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.form-submit:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.form-error {
|
||||
padding: var(--spacing-md);
|
||||
background: #fef2f2;
|
||||
border: 1px solid #fecaca;
|
||||
border-radius: var(--radius);
|
||||
color: #dc2626;
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.form-error {
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
border-color: rgba(239, 68, 68, 0.3);
|
||||
color: #f87171;
|
||||
}
|
||||
}
|
||||
|
||||
.form-success {
|
||||
padding: var(--spacing-2xl);
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-success h2 {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.form-success p {
|
||||
color: var(--color-muted);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.form-reset {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.form-reset:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
position: sticky;
|
||||
top: var(--spacing-xl);
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.info-section h3 {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.info-section p,
|
||||
.info-section a {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
.info-section a {
|
||||
text-decoration: none;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
.info-section a:hover {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.social-links {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.social-links a {
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.contact-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.contact-title {
|
||||
font-size: var(--font-size-3xl);
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
position: static;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: var(--spacing-xl);
|
||||
padding-top: var(--spacing-xl);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.contact-info {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
172
templates/portfolio-cloudflare/src/pages/index.astro
Normal file
172
templates/portfolio-cloudflare/src/pages/index.astro
Normal file
@@ -0,0 +1,172 @@
|
||||
---
|
||||
import { getEmDashCollection, getSiteSettings } from "emdash";
|
||||
import Base from "../layouts/Base.astro";
|
||||
import ProjectCard from "../components/ProjectCard.astro";
|
||||
|
||||
const settings = await getSiteSettings();
|
||||
const { entries: projects, cacheHint } =
|
||||
await getEmDashCollection("projects");
|
||||
|
||||
Astro.cache.set(cacheHint);
|
||||
|
||||
// Get the 4 most recent projects for the homepage
|
||||
const featuredProjects = projects
|
||||
.toSorted((a, b) => {
|
||||
const dateA = a.data.publishedAt?.getTime() ?? 0;
|
||||
const dateB = b.data.publishedAt?.getTime() ?? 0;
|
||||
return dateB - dateA;
|
||||
})
|
||||
.slice(0, 4);
|
||||
---
|
||||
|
||||
<Base>
|
||||
<section class="hero">
|
||||
<h1 class="hero-title">{settings?.title || "Studio"}</h1>
|
||||
<p class="hero-tagline">{settings?.tagline || "Design & Development"}</p>
|
||||
</section>
|
||||
|
||||
{
|
||||
featuredProjects.length > 0 ? (
|
||||
<section class="featured">
|
||||
<header class="section-header">
|
||||
<h2 class="section-title">Selected Work</h2>
|
||||
<a href="/work" class="section-link">
|
||||
View all projects →
|
||||
</a>
|
||||
</header>
|
||||
<div class="projects-grid">
|
||||
{featuredProjects.map((project) => (
|
||||
<ProjectCard
|
||||
title={project.data.title ?? "Untitled"}
|
||||
summary={project.data.summary}
|
||||
featuredImage={project.data.featured_image ?? ""}
|
||||
href={`/work/${project.id}`}
|
||||
client={project.data.client}
|
||||
year={project.data.year}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<section class="empty-state">
|
||||
<h2>No projects yet</h2>
|
||||
<p>Add your first project in the admin panel.</p>
|
||||
<a href="/_emdash/admin/content/projects/new" class="btn">
|
||||
Add a project
|
||||
</a>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.hero {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-4xl) var(--spacing-lg);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: var(--font-size-4xl);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-md);
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.hero-tagline {
|
||||
font-size: var(--font-size-xl);
|
||||
color: var(--color-muted);
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.featured {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: 0 var(--spacing-lg) var(--spacing-4xl);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
padding-bottom: var(--spacing-md);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.section-link {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
text-decoration: none;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
.section-link:hover {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.projects-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: var(--spacing-4xl) var(--spacing-lg);
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.empty-state h2 {
|
||||
font-size: var(--font-size-xl);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
color: var(--color-muted);
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: var(--spacing-sm) var(--spacing-lg);
|
||||
background: var(--color-text);
|
||||
color: var(--color-bg);
|
||||
text-decoration: none;
|
||||
border-radius: var(--radius);
|
||||
font-size: var(--font-size-sm);
|
||||
transition: opacity var(--transition-fast);
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.hero {
|
||||
padding: var(--spacing-3xl) var(--spacing-lg);
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: var(--font-size-3xl);
|
||||
}
|
||||
|
||||
.projects-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-sm);
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
70
templates/portfolio-cloudflare/src/pages/rss.xml.ts
Normal file
70
templates/portfolio-cloudflare/src/pages/rss.xml.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import type { APIRoute } from "astro";
|
||||
import { getEmDashCollection, getSiteSettings } from "emdash";
|
||||
|
||||
export const GET: APIRoute = async ({ site, url }) => {
|
||||
const siteUrl = site?.toString() || url.origin;
|
||||
const settings = await getSiteSettings();
|
||||
const siteTitle = settings?.title || "Studio";
|
||||
const siteDescription = settings?.tagline || "Design & Development";
|
||||
|
||||
const { entries: projects } = await getEmDashCollection("projects", {
|
||||
orderBy: { published_at: "desc" },
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
const items = projects
|
||||
.map((project) => {
|
||||
if (!project.data.publishedAt) return null;
|
||||
const pubDate = project.data.publishedAt.toUTCString();
|
||||
|
||||
const projectUrl = `${siteUrl}/work/${project.id}`;
|
||||
const title = escapeXml(project.data.title || "Untitled");
|
||||
const description = escapeXml(project.data.summary || "");
|
||||
|
||||
return ` <item>
|
||||
<title>${title}</title>
|
||||
<link>${projectUrl}</link>
|
||||
<guid isPermaLink="true">${projectUrl}</guid>
|
||||
<pubDate>${pubDate}</pubDate>
|
||||
<description>${description}</description>
|
||||
</item>`;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
|
||||
const rss = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>${escapeXml(siteTitle)}</title>
|
||||
<description>${escapeXml(siteDescription)}</description>
|
||||
<link>${siteUrl}</link>
|
||||
<atom:link href="${siteUrl}/rss.xml" rel="self" type="application/rss+xml"/>
|
||||
<language>en-us</language>
|
||||
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
|
||||
${items}
|
||||
</channel>
|
||||
</rss>`;
|
||||
|
||||
return new Response(rss, {
|
||||
headers: {
|
||||
"Content-Type": "application/rss+xml; charset=utf-8",
|
||||
"Cache-Control": "public, max-age=3600",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const XML_ESCAPE_PATTERNS = [
|
||||
[/&/g, "&"],
|
||||
[/</g, "<"],
|
||||
[/>/g, ">"],
|
||||
[/"/g, """],
|
||||
[/'/g, "'"],
|
||||
] as const;
|
||||
|
||||
function escapeXml(str: string): string {
|
||||
let result = str;
|
||||
for (const [pattern, replacement] of XML_ESCAPE_PATTERNS) {
|
||||
result = result.replace(pattern, replacement);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
303
templates/portfolio-cloudflare/src/pages/work/[slug].astro
Normal file
303
templates/portfolio-cloudflare/src/pages/work/[slug].astro
Normal file
@@ -0,0 +1,303 @@
|
||||
---
|
||||
import { getEmDashEntry, getEmDashCollection } from "emdash";
|
||||
import { Image, PortableText } from "emdash/ui";
|
||||
import Base from "../../layouts/Base.astro";
|
||||
import ProjectCard from "../../components/ProjectCard.astro";
|
||||
|
||||
const { slug } = Astro.params;
|
||||
|
||||
if (!slug) {
|
||||
return Astro.redirect("/404");
|
||||
}
|
||||
|
||||
const { entry: project, cacheHint } = await getEmDashEntry("projects", slug);
|
||||
|
||||
if (!project) {
|
||||
return Astro.redirect("/404");
|
||||
}
|
||||
|
||||
try {
|
||||
Astro.cache.set(cacheHint);
|
||||
} catch {}
|
||||
|
||||
// Get related projects (same category or just other projects)
|
||||
const { entries: allProjects } = await getEmDashCollection("projects");
|
||||
const otherProjects = allProjects
|
||||
.filter((p) => p.id !== project.id)
|
||||
.slice(0, 2);
|
||||
|
||||
// Parse gallery if present
|
||||
const gallery = project.data.gallery as
|
||||
| Array<{ url: string; alt?: string }>
|
||||
| undefined;
|
||||
|
||||
// Get image src for OG image
|
||||
function getImageSrc(img: unknown): string | undefined {
|
||||
if (!img || typeof img !== "object") return undefined;
|
||||
const image = img as Record<string, unknown>;
|
||||
return typeof image.src === "string" ? image.src : undefined;
|
||||
}
|
||||
---
|
||||
|
||||
<Base
|
||||
title={project.data.title}
|
||||
description={project.data.summary}
|
||||
image={getImageSrc(project.data.featured_image)}
|
||||
>
|
||||
<article class="project">
|
||||
<header class="project-header">
|
||||
<div class="project-meta">
|
||||
{
|
||||
project.data.client && (
|
||||
<span class="project-client" {...project.edit.client}>
|
||||
{project.data.client}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
{
|
||||
project.data.client && project.data.year && (
|
||||
<span class="meta-separator">·</span>
|
||||
)
|
||||
}
|
||||
{
|
||||
project.data.year && (
|
||||
<span class="project-year" {...project.edit.year}>
|
||||
{project.data.year}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<h1 class="project-title" {...project.edit.title}>
|
||||
{project.data.title}
|
||||
</h1>
|
||||
{
|
||||
project.data.summary && (
|
||||
<p class="project-summary" {...project.edit.summary}>
|
||||
{project.data.summary}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
{
|
||||
project.data.url && (
|
||||
<a
|
||||
href={project.data.url ?? "#"}
|
||||
class="project-link"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
View Live Project →
|
||||
</a>
|
||||
)
|
||||
}
|
||||
</header>
|
||||
|
||||
{
|
||||
project.data.featured_image && (
|
||||
<div class="featured-image" {...project.edit.featured_image}>
|
||||
<Image image={project.data.featured_image} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
<div class="project-content">
|
||||
<PortableText value={project.data.content} />
|
||||
</div>
|
||||
|
||||
{
|
||||
gallery && gallery.length > 0 && (
|
||||
<div class="project-gallery">
|
||||
{gallery.map((img) => (
|
||||
<div class="gallery-item">
|
||||
<img src={img.url} alt={img.alt || ""} loading="lazy" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</article>
|
||||
|
||||
{
|
||||
otherProjects.length > 0 && (
|
||||
<section class="more-projects">
|
||||
<div class="more-inner">
|
||||
<h2 class="more-title">More Work</h2>
|
||||
<div class="more-grid">
|
||||
{otherProjects.map((p) => (
|
||||
<ProjectCard
|
||||
title={p.data.title ?? "Untitled"}
|
||||
summary={p.data.summary}
|
||||
featuredImage={p.data.featured_image ?? ""}
|
||||
href={`/work/${p.id}`}
|
||||
client={p.data.client}
|
||||
year={p.data.year}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.project {
|
||||
max-width: var(--max-width);
|
||||
margin: 0 auto;
|
||||
padding: 0 var(--spacing-lg) var(--spacing-4xl);
|
||||
}
|
||||
|
||||
.project-header {
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.project-meta {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.meta-separator {
|
||||
margin: 0 var(--spacing-sm);
|
||||
}
|
||||
|
||||
.project-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-4xl);
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.project-summary {
|
||||
font-size: var(--font-size-lg);
|
||||
color: var(--color-muted);
|
||||
line-height: 1.6;
|
||||
margin-bottom: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.project-link {
|
||||
display: inline-block;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-accent);
|
||||
text-decoration: none;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
.project-link:hover {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.featured-image {
|
||||
margin-bottom: var(--spacing-3xl);
|
||||
}
|
||||
|
||||
.featured-image img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.project-content {
|
||||
font-size: var(--font-size-base);
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.project-content :global(p) {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
.project-content :global(h2) {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-2xl);
|
||||
font-weight: 500;
|
||||
margin-top: 2.5em;
|
||||
margin-bottom: 0.75em;
|
||||
}
|
||||
|
||||
.project-content :global(h3) {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 500;
|
||||
margin-top: 2em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.project-content :global(blockquote) {
|
||||
margin: 2em 0;
|
||||
padding-left: var(--spacing-xl);
|
||||
border-left: 2px solid var(--color-accent);
|
||||
color: var(--color-muted);
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
font-size: var(--font-size-lg);
|
||||
}
|
||||
|
||||
.project-content :global(ul),
|
||||
.project-content :global(ol) {
|
||||
margin-bottom: 1.5em;
|
||||
padding-left: 1.25em;
|
||||
}
|
||||
|
||||
.project-content :global(li) {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.project-content :global(img) {
|
||||
margin: 2em 0;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.project-gallery {
|
||||
margin-top: var(--spacing-3xl);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--spacing-lg);
|
||||
}
|
||||
|
||||
.gallery-item img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.more-projects {
|
||||
background: var(--color-surface);
|
||||
padding: var(--spacing-4xl) 0;
|
||||
margin-top: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.more-inner {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: 0 var(--spacing-lg);
|
||||
}
|
||||
|
||||
.more-title {
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--font-size-2xl);
|
||||
font-weight: 500;
|
||||
margin-bottom: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.more-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.project-title {
|
||||
font-size: var(--font-size-3xl);
|
||||
}
|
||||
|
||||
.project-gallery {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.more-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
220
templates/portfolio-cloudflare/src/pages/work/index.astro
Normal file
220
templates/portfolio-cloudflare/src/pages/work/index.astro
Normal file
@@ -0,0 +1,220 @@
|
||||
---
|
||||
export const prerender = false;
|
||||
|
||||
import {
|
||||
getEmDashCollection,
|
||||
getTaxonomyTerms,
|
||||
getEntryTerms,
|
||||
} from "emdash";
|
||||
import Base from "../../layouts/Base.astro";
|
||||
import ProjectCard from "../../components/ProjectCard.astro";
|
||||
|
||||
const { entries: projects, cacheHint } =
|
||||
await getEmDashCollection("projects");
|
||||
const tags = await getTaxonomyTerms("tag");
|
||||
|
||||
// Get filter from query param
|
||||
const activeTag = Astro.url.searchParams.get("tag");
|
||||
|
||||
// Get tags for each project and filter if needed
|
||||
const projectsWithTags = await Promise.all(
|
||||
projects.map(async (project) => {
|
||||
const projectTags = await getEntryTerms("projects", project.data.id, "tag");
|
||||
return { project, projectTags };
|
||||
})
|
||||
);
|
||||
|
||||
// Filter projects if a tag is selected
|
||||
const filteredProjects = activeTag
|
||||
? projectsWithTags.filter(({ projectTags }) =>
|
||||
projectTags.some((t) => t.slug === activeTag)
|
||||
)
|
||||
: projectsWithTags;
|
||||
|
||||
// Sort by published date
|
||||
const sortedProjects = filteredProjects.toSorted((a, b) => {
|
||||
const dateA = a.project.data.publishedAt?.getTime() ?? 0;
|
||||
const dateB = b.project.data.publishedAt?.getTime() ?? 0;
|
||||
return dateB - dateA;
|
||||
});
|
||||
|
||||
Astro.cache.set(cacheHint);
|
||||
---
|
||||
|
||||
<Base
|
||||
title={activeTag
|
||||
? `${tags.find((t) => t.slug === activeTag)?.label || activeTag} — Work`
|
||||
: "Work"}
|
||||
>
|
||||
<section class="work-header">
|
||||
<h1>Work</h1>
|
||||
<p class="work-intro">
|
||||
A selection of projects spanning branding, web design, print, and
|
||||
photography.
|
||||
</p>
|
||||
|
||||
{
|
||||
tags.length > 0 && (
|
||||
<nav class="tag-filters" aria-label="Filter by tag">
|
||||
{tags.map((tag) => (
|
||||
<a
|
||||
href={`/work?tag=${tag.slug}`}
|
||||
class:list={["tag-filter", { active: activeTag === tag.slug }]}
|
||||
>
|
||||
{tag.label}
|
||||
</a>
|
||||
))}
|
||||
{activeTag && (
|
||||
<a href="/work" class="tag-clear" aria-label="Clear filter">
|
||||
Clear
|
||||
</a>
|
||||
)}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
</section>
|
||||
|
||||
{
|
||||
sortedProjects.length > 0 ? (
|
||||
<section class="projects">
|
||||
<div class="projects-grid">
|
||||
{sortedProjects.map(({ project, projectTags }) => (
|
||||
<ProjectCard
|
||||
title={project.data.title ?? "Untitled"}
|
||||
summary={project.data.summary}
|
||||
featuredImage={project.data.featured_image ?? ""}
|
||||
href={`/work/${project.id}`}
|
||||
client={project.data.client}
|
||||
year={project.data.year}
|
||||
tags={projectTags.map((t) => t.label)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<section class="empty-state">
|
||||
{activeTag ? (
|
||||
<>
|
||||
<p>No projects found with this tag.</p>
|
||||
<a href="/work" class="btn">
|
||||
View all projects
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p>No projects yet. Add your first project in the admin panel.</p>
|
||||
<a href="/_emdash/admin/content/projects/new" class="btn">
|
||||
Add a project
|
||||
</a>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.work-header {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: var(--spacing-3xl) var(--spacing-lg) var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.work-header h1 {
|
||||
font-size: var(--font-size-3xl);
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
|
||||
.work-intro {
|
||||
font-size: var(--font-size-lg);
|
||||
color: var(--color-muted);
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.tag-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--spacing-sm);
|
||||
margin-top: var(--spacing-xl);
|
||||
}
|
||||
|
||||
.tag-filter {
|
||||
display: inline-block;
|
||||
padding: var(--spacing-xs) var(--spacing-md);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
text-decoration: none;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
transition:
|
||||
color var(--transition-fast),
|
||||
border-color var(--transition-fast),
|
||||
background var(--transition-fast);
|
||||
}
|
||||
|
||||
.tag-filter:hover {
|
||||
color: var(--color-text);
|
||||
border-color: var(--color-text);
|
||||
}
|
||||
|
||||
.tag-filter.active {
|
||||
color: var(--color-bg);
|
||||
background: var(--color-text);
|
||||
border-color: var(--color-text);
|
||||
}
|
||||
|
||||
.tag-clear {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
padding: var(--spacing-xs) var(--spacing-md);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-muted);
|
||||
text-decoration: none;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
.tag-clear:hover {
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.tag-clear::before {
|
||||
content: "×";
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.projects {
|
||||
max-width: var(--wide-width);
|
||||
margin: 0 auto;
|
||||
padding: 0 var(--spacing-lg) var(--spacing-4xl);
|
||||
}
|
||||
|
||||
.projects-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--spacing-2xl);
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: var(--spacing-4xl) var(--spacing-lg);
|
||||
color: var(--color-muted);
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
margin-top: var(--spacing-lg);
|
||||
padding: var(--spacing-sm) var(--spacing-lg);
|
||||
background: var(--color-text);
|
||||
color: var(--color-bg);
|
||||
text-decoration: none;
|
||||
border-radius: var(--radius);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.projects-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user