Skip to content

Commit

Permalink
Additional redirects on legacy site
Browse files Browse the repository at this point in the history
  • Loading branch information
chadokruse committed Jan 18, 2025
1 parent 3da409e commit 5f94efa
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 3 deletions.
8 changes: 8 additions & 0 deletions apps/legacy/src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const legacySitemapRedirects: Redirects = {

const surpriseMeRoutes = ['/profiles/v0'];

const deprecatedFullIndexRoute = '/profiles/';
const fullIndexRedirect = '/search/profiles/';

export async function handle({ event, resolve }) {
const path = event.url.pathname;

Expand All @@ -32,6 +35,11 @@ export async function handle({ event, resolve }) {
}
}

// Handle deprecated profiles full index route
if (event.url.pathname === deprecatedFullIndexRoute) {
redirect(301, fullIndexRedirect);
}

return resolve(event);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/legacy/src/lib/components/Footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="col s12 m12 l4">
<div class="left-align">
<ul class="footer-nav list-inline">
<li><a data-sveltekit-reload href="/profiles/">Profiles Index</a></li>
<!-- <li><a data-sveltekit-reload href="/profiles/">Profiles Index</a></li> -->
{#if page && page.ein}
<li>
<a href="mailto:feedback@grantmakers.io?body=%0D%0A%0D%0A{page.organization_name}%0D%0A{site.baseurl}/{page.ein}/"
Expand Down
87 changes: 86 additions & 1 deletion apps/legacy/src/routes/profiles/+page.svelte
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
ok
<!--
Keeping this legacy code around should the /profiles/ full index route need to be recreated
Currently using a server-side redirect via hooks.Server.ts
-->
<script lang="ts">
import { onMount } from 'svelte';
import Header from '$src/lib/components/Header.svelte';
import logo from '$src/lib/assets/legacy/images/logo.png';
import '$lib/assets/legacy/css/main-materialize.css';
import { Server } from '@sveltejs/kit';

Check warning on line 10 in apps/legacy/src/routes/profiles/+page.svelte

View workflow job for this annotation

GitHub Actions / Deploy to Cloudflare

'Server' is defined but never used
onMount(async () => {
let M = await import('materialize-css');
const { initJs } = await import('$lib/assets/legacy/js/pages-materialize');
try {
initJs(M);
} catch (error) {
console.log(error);
}
});
</script>

<Header />

<div class="simple-page">
<main>
<div class="header header-filter" style="background-image: url('/assets/img/files.jpg')"></div>

<div class="main main-raised">
<div class="profile-content">
<div class="row row-alert-fixed-to-top">
<div class="col s12">
<div class="alert-fixed-to-top">
<div class="left">Updated: Jan 17, 2025</div>
<div class="right">153,236 Profiles</div>
</div>
</div>
</div>
<div class="container-custom">
<div class="row">
<div class="col s12">
<div id="profile" class="profile center-align">
<div class="avatar">
<img src={logo} alt="Grantmakers.io Logo" class="img-circle img-responsive" />
</div>
<div class="name">
<h1 class="title">Foundation Profiles</h1>
<h6 class="sub-title">Complete Index</h6>
<p>Psst. Use the <a href="/search/profiles/">main search feature</a> to find profiles.</p>

<div class="row">
<div class="col s12 l8 offset-l2">
<!-- <ul class="list-unstyled">
{#each data as item}
<li class="each-index-item">
<h6>
<span class="hide-on-med-and-down"><small>{item.ein}</small></span>
<a href="/profiles/v0/{item.organization_name_slug}/">{item.organization_name_slug}</a>
</h6>
</li>
{/each}
</ul> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>

<style>
.profile-content #profile {
margin-bottom: 75px;
}
.simple-page .profile img {
width: 100%;
height: 100%;
max-width: 160px;
max-height: 160px;
margin: -80px auto 0;
}
</style>
2 changes: 1 addition & 1 deletion apps/web/src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function handle({ event, resolve }) {
return redirect(301, new URL(legacySitemapRedirects[path], event.url.origin));
}

// Handle legacy profiles 'v' redirect
// Handle legacy profiles version redirect, e.g. /v0
if (path.startsWith('/profiles/v0/')) {
const newPath = path.replace('/profiles/v0/', '/profiles/v1/');
return redirect(301, newPath);
Expand Down

0 comments on commit 5f94efa

Please sign in to comment.