ScullyRoutesService
TheScullyRoutesService provides methods and observables that give you access to all routes rendered by Scully, including their metadata and published status.
Overview
This service reads thescully-routes.json file generated during the Scully build process and exposes various observables to access route information throughout your Angular application.
Installation
The service is automatically available when you importScullyLibModule:
Interface
ScullyRoute
Observables
allRoutes$
reload() is called.
Example:
available$
published !== false).
Emission Pattern: Emits whenever allRoutes$ emits, filtering for published routes.
Example:
unPublished$
published === false).
Emission Pattern: Emits whenever allRoutes$ emits, filtering for unpublished routes.
Example:
topLevel$
available$ emits, filtering for top-level routes.
Example:
Methods
getCurrent()
NavigationEnd event.
Returns: Observable that emits the current ScullyRoute or undefined if not found.
Example:
reload()
scully-routes.json file. Useful when routes are dynamically added and you need to refresh the route list.
Example:
Advanced Usage
Filtering Routes by Custom Properties
Sorting Routes by Date
Building a Tag Cloud
Error Handling
If thescully-routes.json file is not found, the service logs a warning and returns an empty array:
Notes
- All observables use
shareReplaywithrefCount: false, meaning they maintain their last value even without active subscriptions - The service automatically handles duplicate routes that may exist due to multiple slugs
- Routes are loaded from
assets/scully-routes.jsonvia HTTP request - The service is provided in root, making it a singleton across the application

