Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR #321

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

SSR #321

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ dotenv.config();

// https://astro.build/config
export default defineConfig({
output: 'server',
site: 'https://eventua11y.com',
output: 'static',
adapter: netlify(),
integrations: [
vue({
Expand Down
59 changes: 59 additions & 0 deletions src/components/Debug.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div>
<p>Random Number: {{ currentNumber }}</p>
<button type="button" @click="generateNew">Generate New Number</button>
</div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';

export default defineComponent({
name: 'Debug',
props: {
ssrNumber: {
type: Number,
required: true,
},
},
setup(props) {
console.log('Received SSR number:', props.ssrNumber);
const currentNumber = ref(props.ssrNumber);

const generateNew = () => {
currentNumber.value = Math.floor(Math.random() * 100) + 1;
};

return {
currentNumber,
generateNew,
};
},
});
</script>

<style scoped>
.random-number {
padding: 1rem;
text-align: center;
}

.button {
padding: 0.5rem 1rem;
background-color: #4caf50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

.button:hover {
background-color: #45a049;
}

.debug {
color: #666;
font-size: 0.9em;
margin-bottom: 1rem;
}
</style>
11 changes: 11 additions & 0 deletions src/pages/curation-policy.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
---
import DefaultLayout from '../layouts/default.astro';
import Debug from '../components/Debug.vue';

// Disable prerendering to enable SSR
export const prerender = false;

// Generate random number during SSR
const ssrNumber = Math.floor(Math.random() * 1000);
---

<DefaultLayout title="Curation Policy">
<div class="container readable py-l flow">
<h1>Event Curation Policy</h1>

<Debug ssrNumber={ssrNumber} client:load />

<p>Server-side random number: {ssrNumber}</p>

<p>Eventua11y is independently curated by <a href="https://mattobee.com">Matt Obee</a>, guided by this curation policy. None of the events listed have paid to be there. The following criteria is used to evaluate the suitability of events before they appear in the calendar.</p>

<h2>Subject matter</h2>
Expand Down
Empty file added src/pages/index.vue
Empty file.
Loading