@mintlify/previewing 4.0.1444 → 4.0.1446
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,11 +45,20 @@ const decodePathname = (pathname) => {
|
|
|
45
45
|
return pathname;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
const MARKDOWN_PREFIX = '_markdown/';
|
|
49
|
+
const OG_PREVIEW_PREFIX = '_mintlify/og/';
|
|
50
|
+
const OG_PREVIEW_EXTENSION = '.png';
|
|
51
|
+
const pageSlugFromOgPreview = (slug) => {
|
|
52
|
+
if (!slug.startsWith(OG_PREVIEW_PREFIX) || !slug.endsWith(OG_PREVIEW_EXTENSION))
|
|
53
|
+
return undefined;
|
|
54
|
+
return slug.slice(OG_PREVIEW_PREFIX.length, -OG_PREVIEW_EXTENSION.length);
|
|
55
|
+
};
|
|
48
56
|
const slugFromPathname = (pathname) => {
|
|
49
57
|
let slug = decodePathname(pathname).replace(/^\/+/, '').replace(/\/+$/, '');
|
|
50
|
-
if (slug.startsWith(
|
|
51
|
-
slug = slug.slice(
|
|
58
|
+
if (slug.startsWith(MARKDOWN_PREFIX)) {
|
|
59
|
+
slug = slug.slice(MARKDOWN_PREFIX.length);
|
|
52
60
|
}
|
|
61
|
+
slug = pageSlugFromOgPreview(slug) ?? slug;
|
|
53
62
|
if (slug === '') {
|
|
54
63
|
return 'index';
|
|
55
64
|
}
|
|
@@ -50,6 +50,7 @@ export const run = async (argv) => {
|
|
|
50
50
|
const app = express();
|
|
51
51
|
const server = createServer(app);
|
|
52
52
|
const io = new SocketServer(server);
|
|
53
|
+
process.env.LOCAL_OG_PREVIEW = 'true';
|
|
53
54
|
const requestHandler = await timeDev('setup Next handler', () => setupNext());
|
|
54
55
|
const localIp = getLocalNetworkIp();
|
|
55
56
|
const apiUrl = argv.apiUrl ?? process.env.MINTLIFY_API_URL ?? 'http://localhost:5000';
|