You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.4 KiB
2.4 KiB
Component Refactoring Plan for Path-Based Routing
This document outlines the necessary changes to Svelte components to support the new path-based routing for publications.
1. PublicationHeader.svelte
This component generates links to publications and needs to be updated to the new URL format.
Actions:
- Locate
hrefderivation: Find the$derived.byblock that computes thehrefconstant. - Update URL structure: Modify the logic to generate URLs in the format
/publication/[type]/[identifier].- If the event has a
dtag and is a replaceable event (e.g., kind 30040), encode it as annaddrand use the URL/publication/naddr/[naddr]. - If the event is not replaceable but has an ID (like a kind 30041), encode it as an
neventand use the URL/publication/nevent/[nevent]. - Use the existing
naddrEncodeandneventEncodeutilities fromsrc/lib/utils.tsto encode identifiers. - If needed, add new
naddrDecodeandneventDecodeutilities tosrc/lib/utils.ts, leveraging functions from thenip19module in thenostr-toolspackage.
- If the event has a
2. Publication.svelte
This component is responsible for rendering the publication content. The primary changes will be in how data is passed to it, rather than in its internal logic.
Actions:
- Review props: The component accepts
rootAddress,publicationType, andindexEvent. This is good. - Update parent component: The new
src/routes/publication/[type]/[identifier]/+page.sveltewill be responsible for providing these props from the data loaded on the server. No direct changes toPublication.svelteshould be needed unless the data shape from theloadfunction requires it. It is expected that theloadfunction will provide theindexEventdirectly. - Add identifierType prop: If the rendering logic needs to know the original identifier type (e.g.,
id,d,naddr,nevent), introduce a newidentifierTypeprop toPublication.svelte.
3. General Codebase Audit
Other parts of the application might contain hardcoded links to publications using the old query parameter format.
Actions:
- Perform a codebase search: Search for the strings
"publication?id="and"publication?d="to identify any other places where links are constructed. - Update any found links: Refactor any discovered instances to use the new
/publication/[type]/[identifier]format.