Skip to content

Commit fb9245c

Browse files
committed
feat: add rss feed button
1 parent 6e3cab8 commit fb9245c

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/components/NavBar.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
:icon="settings.message.icon"
147147
:color="settings.message.type"
148148
:to="settings.message.link || undefined"
149+
close
149150
class="mb-4"
150151
/>
151152
</template>

src/pages/index.vue

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
@click="refreshPosts"
1010
size="lg"
1111
/>
12+
<UButton
13+
icon="mdi:rss"
14+
color="warning"
15+
variant="outline"
16+
@click="feedOpen = true"
17+
size="lg"
18+
/>
1219
<UButton
1320
v-if="loggedIn"
1421
icon="mdi:plus"
@@ -126,12 +133,51 @@
126133
/>
127134
</template>
128135
</UModal>
136+
<UModal
137+
v-model:open="feedOpen"
138+
title="RSS Feed"
139+
class="min-w-120"
140+
>
141+
<template #body>
142+
<div class="flex flex-col gap-2">
143+
<h1 class="font-medium text-sm">
144+
Subscribe to the RSS feed to learn more: {{ description }}
145+
</h1>
146+
<UInput
147+
disabled
148+
:model-value="`${hostname}/feed.xml`"
149+
/>
150+
<div class="flex gap-2 w-full">
151+
<UButton
152+
color="warning"
153+
icon="mdi:content-copy"
154+
@click="copyToClipboard"
155+
class="w-7/12"
156+
>
157+
Copy to Clipboard
158+
</UButton>
159+
160+
<UButton
161+
color="primary"
162+
:to="`${hostname}/feed.xml`"
163+
target="_blank"
164+
icon="mdi:web"
165+
class="w-5/12"
166+
>
167+
View RSS Feed
168+
</UButton>
169+
</div>
170+
</div>
171+
</template>
172+
</UModal>
129173
</template>
130174

131175
<script setup lang="ts">
132176
const { posts, fetchPosts } = useBlogPosts();
133177
const { loggedIn, isLoggedIn } = useLogin();
134-
const { fetchSettings } = useSettings();
178+
const { settings, fetchSettings } = useSettings();
179+
180+
const config = useRuntimeConfig();
135181
136182
// Check login state during SSR
137183
await isLoggedIn();
@@ -164,4 +210,13 @@ const years = computed(() => {
164210
});
165211
return Array.from(yearSet).sort((a, b) => b - a);
166212
});
213+
214+
const hostname =
215+
config.public.site_url || typeof window !== 'undefined' ? window.location.origin : '';
216+
const description = settings.value.description || config.public.description;
217+
const feedOpen = ref(false);
218+
219+
function copyToClipboard() {
220+
navigator.clipboard.writeText(`${hostname}/rss.xml`);
221+
}
167222
</script>

0 commit comments

Comments
 (0)