website: handle go-get requests statically (#5821)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-05-31 12:51:45 +02:00 committed by GitHub
parent 6c03126076
commit 165305fbfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 27 deletions

View file

@ -29,14 +29,6 @@
status = 301
force = true
# ?go-get=1 downloads
[[redirects]]
from = "/*"
to = "/.netlify/functions/go-get"
status = 200
force = true
query = {go-get = "1"}
# Container registry
[[redirects]]
from = "/v2"

View file

@ -1,19 +0,0 @@
const gitHubNamespace = "goauthentik";
exports.handler = async function (event, context) {
let repo = "";
if (event.path.startsWith("/api")) {
repo = "client-go";
} else if (event.path.startsWith("/terraform-provider-authentik")) {
repo = "terraform-provider-authentik";
} else {
repo = "authentik";
}
return {
statusCode: 200,
headers: {
"content-type": "text/html",
},
body: `<meta name="go-import" content="${event.headers.host}${event.path} git https://github.com/${gitHubNamespace}/${repo}">`,
};
};

23
website/src/pages/api.jsx Normal file
View file

@ -0,0 +1,23 @@
import React from "react";
import Layout from "@theme/Layout";
import Head from "@docusaurus/Head";
import BrowserOnly from "@docusaurus/core/lib/client/exports/BrowserOnly";
function APIPage() {
return (
<Layout title="API">
<Head>
<meta
name="go-import"
content="goauthentik.io/api git https://github.com/goauthentik/client-go"
></meta>
</Head>
<BrowserOnly>
{() => {
window.location.pathname = "/developer-docs/api/";
}}
</BrowserOnly>
</Layout>
);
}
export default APIPage;

View file

@ -2,6 +2,7 @@ import React from "react";
import clsx from "clsx";
import Layout from "@theme/Layout";
import Link from "@docusaurus/Link";
import Head from "@docusaurus/Head";
import BrowserOnly from "@docusaurus/core/lib/client/exports/BrowserOnly";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import useBaseUrl from "@docusaurus/useBaseUrl";
@ -63,6 +64,12 @@ function Home() {
const { siteConfig = {} } = context;
return (
<Layout title="Welcome" description={siteConfig.tagline}>
<Head>
<meta
name="go-import"
content="goauthentik.io git https://github.com/goauthentik/authentik"
></meta>
</Head>
<header className={clsx("hero hero--primary", styles.heroBanner)}>
<div className="container">
<div className="row">

View file

@ -0,0 +1,25 @@
import React from "react";
import Layout from "@theme/Layout";
import Head from "@docusaurus/Head";
import BrowserOnly from "@docusaurus/core/lib/client/exports/BrowserOnly";
function TerraformProviderPage() {
return (
<Layout title="terraform-provider">
<Head>
<meta
name="go-import"
content="goauthentik.io/terraform-provider-authentik git https://github.com/goauthentik/terraform-provider-authentik"
></meta>
</Head>
<BrowserOnly>
{() => {
window.location.assign(
"https://registry.terraform.io/providers/goauthentik/authentik/latest/docs"
);
}}
</BrowserOnly>
</Layout>
);
}
export default TerraformProviderPage;