diff --git a/src/components/admin/settings/general/Update.vue b/src/components/admin/settings/general/Update.vue
index 4bb847e..4b2137a 100644
--- a/src/components/admin/settings/general/Update.vue
+++ b/src/components/admin/settings/general/Update.vue
@@ -10,6 +10,7 @@ const emits = defineEmits<{
}>();
const generalSettings = useGeneralSettings();
+const { updateGeneralSettings } = usePublicGeneralSettings();
// Define form schema and use it in the form handling
const formSchema = toTypedSchema(generalSettingsSchema);
@@ -61,7 +62,7 @@ const onSubmit = handleSubmit(async values => {
method: 'PUT',
body: { ...values },
});
-
+ updateGeneralSettings(values);
emits('saved');
} catch (error) {
console.error("Error saving settings", error);
diff --git a/src/composables/api.ts b/src/composables/api.ts
index bc2ca98..9d5161a 100644
--- a/src/composables/api.ts
+++ b/src/composables/api.ts
@@ -9,14 +9,6 @@ export function useGeneralSettings(config?: string) {
});
}
-export function usePublicGeneralSettings(config?: string) {
- return useFetch
('/api/public/settings', {
- query: {
- config,
- }
- });
-}
-
export function usePublicPostings() {
return useFetch('/api/public/postings');
}
diff --git a/src/composables/public-settings.ts b/src/composables/public-settings.ts
new file mode 100644
index 0000000..365ab47
--- /dev/null
+++ b/src/composables/public-settings.ts
@@ -0,0 +1,19 @@
+import type { GeneralSettings } from '~/schemas/setting';
+
+export function usePublicGeneralSettings() {
+ const generalSettings = useState('public-general-settings');
+ const updateGeneralSettings = (gs: GeneralSettings) => {
+ generalSettings.value = gs;
+ };
+ return { generalSettings, updateGeneralSettings };
+}
+
+export function usePublicOrganizationSettings() {
+ const { generalSettings } = usePublicGeneralSettings();
+ return computed(() => generalSettings.value.organization);
+}
+
+export function usePublicSeoSettings() {
+ const { generalSettings } = usePublicGeneralSettings();
+ return computed(() => generalSettings.value.seo);
+}
diff --git a/src/pages/index.vue b/src/pages/index.vue
index 2a8c65e..3b95e22 100644
--- a/src/pages/index.vue
+++ b/src/pages/index.vue
@@ -1,6 +1,6 @@
@@ -65,19 +65,19 @@ const logoURL = useRemoteAsset(generalSettings.value?.organization.logo as strin
-
{{ generalSettings?.organization.name }}
-
{{ generalSettings?.organization.description }}
+
{{ generalSettings.organization.name }}
+
{{ generalSettings.organization.description }}
-
+
- {{ generalSettings?.organization.location }}
+ {{ generalSettings.organization.location }}
+ class="flex items-center" v-if="generalSettings.organization.links">
{{ link.title }}
@@ -89,7 +89,7 @@ const logoURL = useRemoteAsset(generalSettings.value?.organization.logo as strin
- Open Positions at Nirvana Labs
+ Open Positions at {{ generalSettings.organization.name }}
diff --git a/src/plugins/setup-remote-asset.ts b/src/plugins/setup-remote-asset.ts
deleted file mode 100644
index a0ff283..0000000
--- a/src/plugins/setup-remote-asset.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export default defineNuxtPlugin(async () => {
- const remoteAssetBase = useState("remote-asset-base-url", () => "");
- try {
- const remoteAssetConfig = await useAsyncData('remove-asset-base-url-fetch', () => $fetch("/api/public/remote-assets-config"));
- if(!remoteAssetConfig.data.value?.base) {
- throw new Error("base url not found in response " + remoteAssetConfig.data.value);
- }
- remoteAssetBase.value = remoteAssetConfig.data.value?.base;
- } catch (error) {
- console.error("error fetching remote-asset-config", error);
- }
-})
\ No newline at end of file
diff --git a/src/plugins/setup-state.ts b/src/plugins/setup-state.ts
new file mode 100644
index 0000000..7e94013
--- /dev/null
+++ b/src/plugins/setup-state.ts
@@ -0,0 +1,29 @@
+import type { GeneralSettings } from '~/schemas/setting';
+
+export default defineNuxtPlugin(async () => {
+ const remoteAssetBase = useState('remote-asset-base-url', () => '');
+ try {
+ const remoteAssetConfig = await useAsyncData('remove-asset-base-url-fetch', () =>
+ $fetch('/api/public/remote-assets-config'),
+ );
+ if (!remoteAssetConfig.data.value?.base) {
+ throw new Error('base url not found in response ' + remoteAssetConfig.data.value);
+ }
+ remoteAssetBase.value = remoteAssetConfig.data.value?.base;
+ } catch (error) {
+ console.error('error fetching remote-asset-config', error);
+ }
+
+ const publicGeneralSettings = useState
('public-general-settings');
+ try {
+ const publicGeneralSettingsResponse = await useAsyncData('public-general-settings-fetch', () =>
+ $fetch('/api/public/settings'),
+ );
+ if (!publicGeneralSettingsResponse.data.value) {
+ throw new Error('Invalid response ' + publicGeneralSettingsResponse.data.value);
+ }
+ publicGeneralSettings.value = publicGeneralSettingsResponse.data.value;
+ } catch (error) {
+ console.error('error fetching public-general-settings', error);
+ }
+});
diff --git a/src/schemas/setting.ts b/src/schemas/setting.ts
index 08ab22f..4004eec 100644
--- a/src/schemas/setting.ts
+++ b/src/schemas/setting.ts
@@ -15,7 +15,7 @@ export const organizationConfigSchema = z
name: z.string().max(36).min(1),
description: z.string().nullable().optional(),
location: z.string().max(24).nullable().optional(),
- logo: z.string().uuid().nullable().optional(),
+ logo: z.string().uuid(),
links: z
.array(
z.object({