Skip to main content
ESC

Get Metadata

getMetadata generates a metadata object for the current structure (including those automatically generated during initialization).

Metadata Generation 

To collect metadata, Robindoc supports front-matter:

---
title: "Get Metadata | Robindoc"
description: "Robindoc AAAAAA"
---

If you do not provide a front-matter title, the first-level heading of the page will be used as the title.

Usage 

getMetadata is obtained as a result of initializing Robindoc.

For more details on using the utility in your application, refer to the section App Organization.

You can get the metadata object for a specific page using the following method:

TypeScript
JavaScript
import { getMetadata } from "./robindoc";

export const generateMetadata = async ({
params,
}: {
params: { segments?: string[] };
}) => {
const pathname = "/docs/" + (params.segments?.join("/") || "");
const metadata = await getMetadata(pathname);

return metadata;
};
import { getMetadata } from "./robindoc";

export const generateMetadata = async ({ params }) => {
const { segments } = await params;
const pathname = "/docs/" + (segments?.join("/") || "");
const metadata = await getMetadata(pathname);

return metadata;
};

Arguments 

pathname - the full path of the current page (f.e., /docs/02-tools/get-metadata) must be provided to obtain the metadata.

Previous
Tools
Next
Get Page Data
Return to navigation