mirror of
https://github.com/goauthentik/authentik
synced 2026-04-27 18:07:15 +02:00
* website: Unify Netlify redirects with Docusaurus's client-side router. * website: Flesh out client-redirects. * Potential fix for code scanning alert no. 256: Incomplete string escaping or encoding Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> * website: Use package. * website: use permanent redirect. * Apply suggestions from code review Co-authored-by: Dewi Roberts <dewi@goauthentik.io> Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Dewi Roberts <dewi@goauthentik.io> Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> * website: Spelling. * website: Add link. * website: Clarify. * website: Remove doc. * website: Add redirects for API and integrations. --------- Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Dewi Roberts <dewi@goauthentik.io>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { RedirectEntry } from "@goauthentik/docusaurus-theme/redirects";
|
|
import type { AKRedirectsPluginData } from "@goauthentik/docusaurus-theme/redirects/plugin";
|
|
|
|
import { usePluginData } from "@docusaurus/useGlobalData";
|
|
|
|
/**
|
|
* Hook to retrieve redirects provided by the client-side redirects plugin.
|
|
*/
|
|
export function useRedirectEntries(): RedirectEntry[] | null {
|
|
const pluginData = usePluginData("ak-redirects-plugin", undefined) as
|
|
| AKRedirectsPluginData
|
|
| undefined;
|
|
|
|
if (!pluginData || !pluginData.redirects) {
|
|
return null;
|
|
}
|
|
|
|
return pluginData.redirects;
|
|
}
|
|
|
|
/**
|
|
* Given a URL-like object, return the pathname (i.e. suffix), and the combination query string, hash, etc (i.e. prefix).
|
|
*/
|
|
export function pluckPathnameAffixes(
|
|
url: Pick<URL, "pathname" | "href" | "origin">,
|
|
): [prefix: string, suffix: string] {
|
|
const [, fullPathname = ""] = url.href.split(window.location.origin);
|
|
|
|
if (!fullPathname) return ["", ""];
|
|
|
|
const suffix = fullPathname.slice(url.pathname.length);
|
|
|
|
return [url.pathname, suffix];
|
|
}
|