* docs: migrate ui docs to docs universe * created yarn workspace * added eslint and tsconfig configurations * fix eslint configurations * fixed eslint configurations * shared tailwind configurations * added shared ui package * added more shared components * migrating more components * made details components shared * move InlineCode component * moved InputText * moved Loading component * Moved Modal component * moved Select components * Moved Tooltip component * moved Search components * moved ColorMode provider * Moved Notification components and providers * used icons package * use UI colors in api-reference * moved Navbar component * used Navbar and Search in UI docs * added Feedback to UI docs * general enhancements * fix color mode * added copy colors file from ui-preset * added features and enhancements to UI docs * move Sidebar component and provider * general fixes and preparations for deployment * update docusaurus version * adjusted versions * fix output directory * remove rootDirectory property * fix yarn.lock * moved code component * added vale for all docs MD and MDX * fix tests * fix vale error * fix deployment errors * change ignore commands * add output directory * fix docs test * general fixes * content fixes * fix announcement script * added changeset * fix vale checks * added nofilter option * fix vale error
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { MetadataRoute } from "next"
|
|
import OpenAPIParser from "@readme/openapi-parser"
|
|
import path from "path"
|
|
import getBaseUrl from "../../utils/get-base-url"
|
|
import type { ExpandedDocument, Operation } from "../../types/openapi"
|
|
import getUrl from "../../utils/get-url"
|
|
import getSectionId from "../../utils/get-section-id"
|
|
import getPathsOfTag from "../../utils/get-paths-of-tag"
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const baseUrl = getBaseUrl()
|
|
|
|
const results = [
|
|
{
|
|
url: `${baseUrl}/api/admin`,
|
|
lastModified: new Date(),
|
|
},
|
|
{
|
|
url: `${baseUrl}/api/store`,
|
|
lastModified: new Date(),
|
|
},
|
|
]
|
|
|
|
for (const area of ["store", "admin"]) {
|
|
const baseSpecs = (await OpenAPIParser.parse(
|
|
path.join(process.cwd(), `specs/${area}/openapi.yaml`)
|
|
)) as ExpandedDocument
|
|
|
|
await Promise.all(
|
|
baseSpecs.tags?.map(async (tag) => {
|
|
const tagName = getSectionId([tag.name])
|
|
const url = getUrl(area, tagName)
|
|
results.push({
|
|
url,
|
|
lastModified: new Date(),
|
|
})
|
|
|
|
const paths = await getPathsOfTag(tagName, area)
|
|
|
|
Object.values(paths.paths).forEach((path) => {
|
|
Object.values(path).forEach((op) => {
|
|
const operation = op as Operation
|
|
const operationName = getSectionId([
|
|
tag.name,
|
|
operation.operationId,
|
|
])
|
|
const url = getUrl(area, operationName)
|
|
results.push({
|
|
url,
|
|
lastModified: new Date(),
|
|
})
|
|
})
|
|
})
|
|
}) || []
|
|
)
|
|
}
|
|
|
|
return results
|
|
}
|