-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #857 from tradingstrategy-ai/856-strategy-microsite
Strategy microsite
- Loading branch information
Showing
7 changed files
with
95 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
// Make admin, ipCountry and announcementDismissedAt available to all layouts/pages | ||
export async function load({ locals }) { | ||
import { strategyMicrosite } from '$lib/config'; | ||
import { error, redirect } from '@sveltejs/kit'; | ||
|
||
export async function load({ locals, route }) { | ||
// restrict routes on custom strategy site | ||
if (strategyMicrosite) { | ||
restrictMicrositeRoutes(route.id!, strategyMicrosite); | ||
} | ||
|
||
// Make admin, ipCountry and announcementDismissedAt available to all layouts/pages | ||
const { admin, ipCountry, announcementDismissedAt } = locals; | ||
return { admin, ipCountry, announcementDismissedAt }; | ||
} | ||
|
||
function restrictMicrositeRoutes(routeId: string, strategyId: string) { | ||
// redirect home page to strategy page | ||
if (routeId === '/') redirect(302, `/strategies/${strategyId}`); | ||
|
||
// return 404 for all pages other than strategies, glossary and diagnostics | ||
const segments = routeId.split('/').slice(1); | ||
if (!['strategies', 'glossary', 'diagnostics'].includes(segments[0])) { | ||
error(404, 'Not found'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters