Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475// Viewer-request function for the substandard.blog distribution// (aws_cloudfront_function.trailing_slash in main.tf).//// Astro builds with trailingSlash "never" but emits directory output: the// page at /posts/x is the S3 object posts/x/index.html. Extensionless URIs// are rewritten to that object, and trailing-slash URIs are 301-redirected// to the no-slash address — standard.site document records claim the// no-slash address as canonical, so /posts/x/ and /posts/x must stay one// page.
// panoptiblog's own address. The page is built at /panoptiblog, so the// subdomain's root is the one path that has to be rewritten to reach it.var PANOPTIBLOG_HOST = 'panoptiblog.substandard.blog';var MAIN_HOST = 'substandard.blog';
function hostOf(request) { var host = request.headers && request.headers.host; return host && host.value ? host.value : '';}
function handler(event) { var request = event.request; var uri = request.uri;
if (hostOf(request) === PANOPTIBLOG_HOST && uri === '/') { request.uri = '/panoptiblog/index.html'; return request; }
// The sub-page has its own address now. Send the old path there instead of // serving a second canonical copy. if (hostOf(request) === MAIN_HOST && (uri === '/panoptiblog' || uri === '/panoptiblog/')) { return { statusCode: 301, statusDescription: 'Moved Permanently', headers: { location: { value: 'https://' + PANOPTIBLOG_HOST + '/' + search(request.querystring) }, }, }; }
if (uri === '/') { // default_root_object serves index.html at the distribution root. return request; }
if (uri.endsWith('/')) { var canonical = uri.replace(/\/+$/, '') || '/'; return { statusCode: 301, statusDescription: 'Moved Permanently', headers: { location: { value: canonical + search(request.querystring) } }, }; }
if (!uri.split('/').pop().includes('.')) { request.uri = uri + '/index.html'; }
return request;}
// Rebuild the query string for the redirect Location header; the event// carries it as an object, not on the uri.function search(querystring) { var parts = []; Object.keys(querystring).forEach(function (key) { var values = querystring[key].multiValue || [querystring[key]]; values.forEach(function (entry) { parts.push(entry.value === '' ? key : key + '=' + entry.value); }); }); return parts.length ? '?' + parts.join('&') : '';}