Skip to content

Instantly share code, notes, and snippets.

@mitcdh
Created January 13, 2024 08:45
Show Gist options
  • Save mitcdh/480fa3187a2fe505df7c4cce84516a8f to your computer and use it in GitHub Desktop.
Save mitcdh/480fa3187a2fe505df7c4cce84516a8f to your computer and use it in GitHub Desktop.
Snippets for a post on creating a custom landing page using Cloudflare Pages
/blog/* https://blog.mitcdh.au/:splat 301
/feed/* https://blog.mitcdh.au/feed
/cb2geochart https://mitcdh.github.io/cb2geochart
const base = 'https://mitcdh.au';
const statusCode = 301;
async function handleRequest(request) {
const url = new URL(request.url);
const { pathname, search } = url;
const destinationURL = base + pathname + search;
return Response.redirect(destinationURL, statusCode);
}
addEventListener('fetch', async event => {
event.respondWith(handleRequest(event.request));
});
{
"greetings": [
{
"message": "G'day Mates",
"code": "en",
"font": "Noto Sans"
},
{
"message": "Ciao Amici",
"code": "it",
"font": "Noto Sans"
},
{
"message": "Salut les Amis",
"code": "fr",
"font": "Noto Sans"
},
{
"message": "¡Hola Amigos!",
"code": "es",
"font": "Noto Sans"
},
{
"message": "Привет друзья",
"code": "ru",
"font": "Noto Sans"
},
{
"message": "大家好",
"code": "zh",
"font": "Noto Sans TC"
},
{
"message": "مرحبا اصدقء",
"code": "ar",
"font": "Noto Sans Arabic"
},
{
"message": "Servus, Liebe Freunde",
"code": "de",
"font": "Noto Sans"
},
{
"message": "Alô Galera",
"code": "pt",
"font": "Noto Sans"
},
{
"message": "안녕하세요 친구",
"code": "ko",
"font": "Noto Sans KR"
},
{
"message": "皆さん、こんにちは",
"code": "ja",
"font": "Noto Sans JP"
},
{
"message": "Hej Mina Vänner",
"code": "sv",
"font": "Noto Sans"
},
{
"message": "Selam Dostlar",
"code": "tr",
"font": "Noto Sans"
},
{
"message": "Pozdravljeni Prijatelji",
"code": "sl",
"font": "Noto Sans"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment