mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-10 10:25:03 +00:00
docs(plugins): consolidate guides and document npm publishing
This commit is contained in:
@@ -157,15 +157,15 @@ export function getDoc(slug: string): Doc | undefined {
|
||||
return getDocs().find((d) => d.slug === slug);
|
||||
}
|
||||
|
||||
const legacyPluginDocRedirects: Readonly<Record<string, string>> = {
|
||||
"/docs/plugins/reference": "/docs/plugins/v0.7/reference",
|
||||
"/docs/plugins/reference.md": "/docs/plugins/v0.7/reference.md",
|
||||
"/docs/plugins/migration": "/docs/plugins/v0.8/migration",
|
||||
"/docs/plugins/migration.md": "/docs/plugins/v0.8/migration.md",
|
||||
};
|
||||
|
||||
export function getLegacyDocsRedirect(pathname: string): string | undefined {
|
||||
return legacyPluginDocRedirects[pathname];
|
||||
const match =
|
||||
/^\/docs\/plugins\/v0\.[78](?:(\.md)|\/(index|reference|providers|migration)(\.md)?)?\/?$/.exec(
|
||||
pathname,
|
||||
);
|
||||
if (!match) return undefined;
|
||||
const page = match[2] && match[2] !== "index" ? `/${match[2]}` : "";
|
||||
const extension = match[1] || match[3] ? ".md" : "";
|
||||
return `/docs/plugins${page}${extension}`;
|
||||
}
|
||||
|
||||
function formatLabel(segment: string): string {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildDocsNavTree, getDocs, getLegacyDocsRedirect } from "./docs";
|
||||
import { buildDocsNavTree, getDoc, getDocs, getLegacyDocsRedirect } from "./docs";
|
||||
|
||||
describe("versioned plugin documentation", () => {
|
||||
it("keeps stable and beta releases together in the Plugins navigation", () => {
|
||||
describe("plugin documentation", () => {
|
||||
it("groups current guides by task without version navigation", () => {
|
||||
const plugins = buildDocsNavTree(getDocs()).find(
|
||||
(node) => node.type === "category" && node.label === "Plugins",
|
||||
);
|
||||
@@ -10,35 +10,32 @@ describe("versioned plugin documentation", () => {
|
||||
expect(plugins).toMatchObject({
|
||||
type: "category",
|
||||
children: [
|
||||
{ type: "page", label: "Versions", href: "/docs/plugins" },
|
||||
{
|
||||
type: "group",
|
||||
label: "Paseo v0.7 — Current",
|
||||
href: "/docs/plugins/v0.7",
|
||||
children: [{ type: "page", label: "Reference", href: "/docs/plugins/v0.7/reference" }],
|
||||
},
|
||||
{
|
||||
type: "group",
|
||||
label: "Paseo v0.8 — Beta",
|
||||
href: "/docs/plugins/v0.8",
|
||||
children: [
|
||||
{ type: "page", label: "Provider plugins", href: "/docs/plugins/v0.8/providers" },
|
||||
{ type: "page", label: "Migration", href: "/docs/plugins/v0.8/migration" },
|
||||
{ type: "page", label: "Reference", href: "/docs/plugins/v0.8/reference" },
|
||||
],
|
||||
},
|
||||
{ type: "page", label: "Quickstart", href: "/docs/plugins" },
|
||||
{ type: "page", label: "Publishing", href: "/docs/plugins/publishing" },
|
||||
{ type: "page", label: "Provider plugins", href: "/docs/plugins/providers" },
|
||||
{ type: "page", label: "Migration", href: "/docs/plugins/migration" },
|
||||
{ type: "page", label: "Reference", href: "/docs/plugins/reference" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps existing plugin documentation URLs working", () => {
|
||||
expect(getLegacyDocsRedirect("/docs/plugins/reference")).toBe("/docs/plugins/v0.7/reference");
|
||||
expect(getLegacyDocsRedirect("/docs/plugins/reference.md")).toBe(
|
||||
"/docs/plugins/v0.7/reference.md",
|
||||
);
|
||||
expect(getLegacyDocsRedirect("/docs/plugins/migration")).toBe("/docs/plugins/v0.8/migration");
|
||||
expect(getLegacyDocsRedirect("/docs/plugins/migration.md")).toBe(
|
||||
"/docs/plugins/v0.8/migration.md",
|
||||
);
|
||||
it.each(["v0.7", "v0.8"])("redirects %s links to existing current pages", (version) => {
|
||||
for (const page of ["", "/index", "/reference", "/providers", "/migration"]) {
|
||||
const target = `/docs/plugins${page === "/index" ? "" : page}`;
|
||||
expect(getDoc(target.slice("/docs/".length))).toBeDefined();
|
||||
for (const extension of ["", ".md"]) {
|
||||
const source = `/docs/plugins/${version}${page}${extension}`;
|
||||
expect(getLegacyDocsRedirect(source)).toBe(`${target}${extension}`);
|
||||
expect(getLegacyDocsRedirect(`${source}/`)).toBe(`${target}${extension}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("serves canonical pages without redirect loops", () => {
|
||||
for (const page of ["", "/publishing", "/reference", "/providers", "/migration"]) {
|
||||
expect(getLegacyDocsRedirect(`/docs/plugins${page}`)).toBeUndefined();
|
||||
expect(getLegacyDocsRedirect(`/docs/plugins${page}.md`)).toBeUndefined();
|
||||
}
|
||||
expect(getLegacyDocsRedirect("/docs/plugins/v0.8/unknown")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user