Skip to content

Commit

Permalink
Simplify redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEtchells committed Dec 3, 2024
1 parent 7e0662d commit fc634c2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 80 deletions.
23 changes: 0 additions & 23 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const {
const showdown = require("showdown");
const mdToHtmlConverter = new showdown.Converter();

require('dotenv').config();

module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({
"./public/": "/",
Expand Down Expand Up @@ -206,27 +204,6 @@ module.exports = function (eleventyConfig) {
});
})();

// Add redirect configuration
eleventyConfig.addPlugin(function(eleventyConfig) {
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function(err, bs) {
bs.addMiddleware("*", (req, res) => {
if (req.url === '/hack/') {
res.writeHead(301, { // Changed from 302 to 301 for permanent redirect
location: process.env.HACK_REDIRECT_URL || 'https://andreasthinks.github.io/evidence-house/'
});
res.end();
}
});
}
}
});
});

// Make redirect URL available to templates
eleventyConfig.addGlobalData("hackRedirectUrl", process.env.HACK_REDIRECT_URL || 'https://andreasthinks.github.io/evidence-house/');

return {
pathPrefix: "/",
templateFormats: ["njk"],
Expand Down
1 change: 0 additions & 1 deletion .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ CONTENTFUL_SPACE=
CONTENTFUL_ACCESS_TOKEN=
PREVIEW_ACCESS_TOKEN=
CMS_REPO_TOKEN=
HACK_REDIRECT_URL=https://andreasthinks.github.io/evidence-house/
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ For local development without CMS access, you can use test credentials in your `
CONTENTFUL_SPACE=test
CONTENTFUL_ACCESS_TOKEN=test
PREVIEW_ACCESS_TOKEN=test
CMS_REPO_TOKEN=test
```

When using these test credentials:
Expand All @@ -46,15 +45,6 @@ This is useful for:

For full functionality with real data, replace these test values with actual CMS credentials.

### Redirect Configuration
The `/hack` redirect URL can be configured using the `HACK_REDIRECT_URL` environment variable:

```
HACK_REDIRECT_URL=https://your-redirect-url.com
```

If not specified, it defaults to 'https://andreasthinks.github.io/evidence-house/'.


## Cached stylesheets and JavaScript

Expand Down
40 changes: 1 addition & 39 deletions src/_data/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,7 @@ const CMS_REPO = "i-dot-ai/ai-gov-uk-cms-content";

// Return static projects if using test credentials
if (process.env.CONTENTFUL_ACCESS_TOKEN === 'test') {
module.exports = async () => [
{
title: "Consult",
phase: "Alpha",
url: "/projects/consult",
img: "/img/consultation4.png",
synopsis:
"An AI-powered tool to automate the processing of public consultations",
},
{
title: "Redbox",
phase: "Beta",
url: "/projects/redbox",
img: "/img/redbox4.png",
synopsis:
"Redbox is a service that harnesses AI to help you summarise, and ask questions of, documents up to OFFICIAL-SENSITIVE",
},
{
title: "Caddy",
phase: "Scaling",
url: "/projects/caddy",
img: "/img/caddy1.png",
synopsis:
"Our AI powered copilot for customer service agents across government and beyond",
},
{
title: "rAPId",
url: "/projects/rapid",
img: "/img/rapid2.webp",
synopsis: "An end-to-end solution to sharing data across government",
},
{
title: "i.AI and NHS England Collaboration Charter",
url: "/projects/nhs-collaboration",
img: "/img/nhs2.png",
synopsis:
"i.AI and NHS England sign Collaboration Charter to support the use of AI in the NHS",
},
];
module.exports = async () => [];
return;
}

Expand Down
11 changes: 4 additions & 7 deletions src/hack.njk
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
---
permalink: /hack/index.html
---

{% set hackRedirectUrl = "https://andreasthinks.github.io/evidence-house/" %}

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;url={{ hackRedirectUrl }}">
<meta http-equiv="Link" content="<{{ hackRedirectUrl }}>; rel=permanent">
<link rel="canonical" href="{{ hackRedirectUrl }}">
<title>Permanent Redirect</title>
<script>
// Add canonical link to indicate permanent redirect
var link = document.createElement('link');
link.rel = 'canonical';
link.href = '{{ hackRedirectUrl }}';
document.head.appendChild(link);
</script>
</head>
<body>
<p>This page has been permanently moved to <a href="{{ hackRedirectUrl }}">{{ hackRedirectUrl }}</a></p>
Expand Down

0 comments on commit fc634c2

Please sign in to comment.