diff --git a/docs/src/lib/stores/plugin.ts b/docs/src/lib/stores/plugin.ts
index 201c6bd..d7187e5 100644
--- a/docs/src/lib/stores/plugin.ts
+++ b/docs/src/lib/stores/plugin.ts
@@ -1,3 +1,4 @@
+import { snakeCase } from 'change-case';
import { findMetadata } from '$lib/data';
import metadata from '$lib/data/metadata.json';
import { persistent } from '$stores/persistent';
@@ -24,8 +25,14 @@ class CurrentPlugin {
export const currentPlugin = new CurrentPlugin();
-export const currentMetadata = derived(currentPlugin, derive, findMetadata(DEFAULT_PLUGIN));
+export const currentMetadata = derived(currentPlugin, deriveMetadata, findMetadata(DEFAULT_PLUGIN));
-function derive(current: TauriPlugin | null) {
+function deriveMetadata(current: TauriPlugin | null) {
return findMetadata(current ?? DEFAULT_PLUGIN);
}
+
+export function getCollectionName(plugin: Metadata, transform = snakeCase) {
+ return (plugin.name as TauriPlugin) === 'tauri-store'
+ ? transform('store_collection')
+ : transform(plugin.title);
+}
diff --git a/docs/src/routes/guide/accessing-from-rust/+page.svelte b/docs/src/routes/guide/accessing-from-rust/+page.svelte
index ef6469c..65f3236 100644
--- a/docs/src/routes/guide/accessing-from-rust/+page.svelte
+++ b/docs/src/routes/guide/accessing-from-rust/+page.svelte
@@ -2,21 +2,20 @@
import { Ext } from '$components/link';
import { pascalCase } from 'change-case';
import { CodeBlock } from '$components/code';
- import { currentMetadata } from '$stores/plugin';
import { Container } from '$components/container';
import { Breadcrumb } from '$components/breadcrumb';
+ import { currentMetadata, getCollectionName } from '$stores/plugin';
import { get, tryGet, watchStore } from '$content/guide/accessing-from-rust/snippets';
const url = $derived.by(() => {
const docs = $currentMetadata.docs;
- const title = $currentMetadata.title;
- const pascalTitle = pascalCase(title);
+ const collection = getCollectionName($currentMetadata, pascalCase);
return {
// Rust
ManagerExt: `${docs.rust}/trait.ManagerExt.html`,
Store: `${docs.rust}/struct.Store.html`,
- try_get: `${docs.rust}/struct.${pascalTitle}.html#method.try_get`,
- watch: `${docs.rust}/struct.${pascalTitle}.html#method.watch`,
+ try_get: `${docs.rust}/struct.${collection}.html#method.try_get`,
+ watch: `${docs.rust}/struct.${collection}.html#method.watch`,
// Tauri
AppHandle: 'https://docs.rs/tauri/latest/tauri/struct.AppHandle.html',
diff --git a/docs/src/routes/guide/lifecycle-hooks/+page.svelte b/docs/src/routes/guide/lifecycle-hooks/+page.svelte
index 9040f5b..eee5976 100644
--- a/docs/src/routes/guide/lifecycle-hooks/+page.svelte
+++ b/docs/src/routes/guide/lifecycle-hooks/+page.svelte
@@ -16,10 +16,7 @@
const docs = $currentMetadata.docs;
return {
// JavaScript
- beforeBackendSync: `${docs.javascript}/interfaces/StoreHooks.html#beforebackendsync`,
- beforeFrontendSync: `${docs.javascript}/interfaces/StoreHooks.html#beforefrontendsync`,
- hooks: `${docs.javascript}/interfaces/StoreFrontendOptions.html#hooks`,
- error: `${docs.javascript}/interfaces/StoreHooks.html#error`,
+ StoreHooks: `${docs.javascript}/types/StoreHooks.html`,
// Rust
on_load: `${docs.rust}/struct.Builder.html#method.on_load`,
@@ -51,16 +48,12 @@
- JavaScript hooks can be registered using the {@render ext('hooks')} option.
+ JavaScript hooks can be registered using the {@render ext('StoreHooks', 'hooks')} option.
- {#snippet titleSnippet({ title })}
- {title}
- {/snippet}
-
Registers a hook to be called before a store sends its state to Rust. This can be used to modify
the state before it is sent to the backend.
@@ -79,10 +72,6 @@
- {#snippet titleSnippet({ title })}
- {title}
- {/snippet}
-
Registers a hook to be called before a store attempts to update itself with data from Rust. This
can be used to modify the state before the changes are applied.
@@ -92,10 +81,6 @@
- {#snippet titleSnippet({ title })}
- {title}
- {/snippet}
-
Registers a hook to be called when an error is thrown by a store.
diff --git a/docs/src/routes/guide/persisting-state/+page.svelte b/docs/src/routes/guide/persisting-state/+page.svelte
index 96ff9bd..cf1201a 100644
--- a/docs/src/routes/guide/persisting-state/+page.svelte
+++ b/docs/src/routes/guide/persisting-state/+page.svelte
@@ -18,7 +18,7 @@
const docs = $currentMetadata.docs;
return {
// JavaScript
- saveOnChange: `${docs.javascript}/interfaces/StoreBackendOptions.html#saveonchange`,
+ StoreBackendOptions: `${docs.javascript}/types/StoreBackendOptions.html`,
// Rust
autosave: `${docs.rust}/struct.Builder.html#method.autosave`,
@@ -54,7 +54,7 @@
If there's a need to save a store whenever its state changes, you can enable the
- {@render ext('saveOnChange')} option when defining the store.
+ {@render ext('StoreBackendOptions', 'saveOnChange')} option when defining the store.