mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
Correctly strip lang from path
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
This commit is contained in:
Vendored
+1
@@ -16,4 +16,5 @@ export declare class BlogPlugin {
|
||||
loadInstance: (plugin: LoadedPlugin) => Promise<void>;
|
||||
generate: () => Promise<void>;
|
||||
getHtmlPath: (permalink: string, baseUrl?: string) => string;
|
||||
stripLangFromPath: (path: string) => string;
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ class BlogPlugin {
|
||||
bar.stop();
|
||||
logger_1.default.success('Generated og images for blog pages');
|
||||
};
|
||||
getHtmlPath = (permalink, baseUrl) => path.join(this.context.outDir, permalink, 'index.html');
|
||||
getHtmlPath = (permalink, baseUrl) => path.join(this.stripLangFromPath(this.context.outDir), permalink, 'index.html');
|
||||
stripLangFromPath = (path) => {
|
||||
const lang = this.context.i18n.locales.find((locale) => path.endsWith(`/${locale}`));
|
||||
return lang ? path.slice(0, -lang.length - 1) : path;
|
||||
};
|
||||
}
|
||||
exports.BlogPlugin = BlogPlugin;
|
||||
|
||||
Vendored
+1
@@ -19,4 +19,5 @@ export declare class DocsPlugin {
|
||||
loadVersion: (options: DocsPluginOptions, version: LoadedVersion) => Promise<void>;
|
||||
generate: () => Promise<void>;
|
||||
getHtmlPath: (doc: Partial<DocsPageData>) => string | undefined;
|
||||
stripLangFromPath: (path: string) => string;
|
||||
}
|
||||
|
||||
@@ -71,9 +71,11 @@ class DocsPlugin {
|
||||
bar.stop();
|
||||
logger_1.default.success('Generated og images for docs pages');
|
||||
};
|
||||
getHtmlPath = (doc) =>
|
||||
// slug is used here instead of permalink because permalink already contains version and locale paths of websiteOutDir
|
||||
doc.metadata?.slug &&
|
||||
path.join(this.context.outDir, doc.metadata.slug, 'index.html');
|
||||
getHtmlPath = (doc) => doc.metadata?.permalink &&
|
||||
path.join(this.stripLangFromPath(this.context.outDir), doc.metadata.permalink, 'index.html');
|
||||
stripLangFromPath = (path) => {
|
||||
const lang = this.context.i18n.locales.find((locale) => path.endsWith(`/${locale}`));
|
||||
return lang ? path.slice(0, -lang.length - 1) : path;
|
||||
};
|
||||
}
|
||||
exports.DocsPlugin = DocsPlugin;
|
||||
|
||||
Vendored
+1
@@ -16,4 +16,5 @@ export declare class PagesPlugin {
|
||||
loadInstance: (plugin: LoadedPlugin) => Promise<void>;
|
||||
generate: () => Promise<void>;
|
||||
getHtmlPath: (permalink: string) => string;
|
||||
stripLangFromPath: (path: string) => string;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,10 @@ class PagesPlugin {
|
||||
bar.stop();
|
||||
logger_1.default.success('Generated og images for pages');
|
||||
};
|
||||
getHtmlPath = (permalink) => path.join(this.context.outDir, permalink, 'index.html');
|
||||
getHtmlPath = (permalink) => path.join(this.stripLangFromPath(this.context.outDir), permalink, 'index.html');
|
||||
stripLangFromPath = (path) => {
|
||||
const lang = this.context.i18n.locales.find((locale) => path.endsWith(`/${locale}`));
|
||||
return lang ? path.slice(0, -lang.length - 1) : path;
|
||||
};
|
||||
}
|
||||
exports.PagesPlugin = PagesPlugin;
|
||||
|
||||
@@ -148,5 +148,9 @@ export class BlogPlugin {
|
||||
}
|
||||
|
||||
getHtmlPath = (permalink: string, baseUrl?: string) =>
|
||||
path.join(this.context.outDir, permalink, 'index.html')
|
||||
path.join(this.stripLangFromPath(this.context.outDir), permalink, 'index.html')
|
||||
stripLangFromPath = (path: string) => {
|
||||
const lang = this.context.i18n.locales.find((locale) => path.endsWith(`/${locale}`))
|
||||
return lang ? path.slice(0, -lang.length - 1) : path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,10 @@ export class DocsPlugin {
|
||||
}
|
||||
|
||||
getHtmlPath = (doc: Partial<DocsPageData>) =>
|
||||
// slug is used here instead of permalink because permalink already contains version and locale paths of websiteOutDir
|
||||
doc.metadata?.slug &&
|
||||
path.join(this.context.outDir, doc.metadata.slug, 'index.html')
|
||||
doc.metadata?.permalink &&
|
||||
path.join(this.stripLangFromPath(this.context.outDir), doc.metadata.permalink, 'index.html')
|
||||
stripLangFromPath = (path: string) => {
|
||||
const lang = this.context.i18n.locales.find((locale) => path.endsWith(`/${locale}`))
|
||||
return lang ? path.slice(0, -lang.length - 1) : path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,5 +109,9 @@ export class PagesPlugin {
|
||||
}
|
||||
|
||||
getHtmlPath = (permalink: string) =>
|
||||
path.join(this.context.outDir, permalink, 'index.html')
|
||||
path.join(this.stripLangFromPath(this.context.outDir), permalink, 'index.html')
|
||||
stripLangFromPath = (path: string) => {
|
||||
const lang = this.context.i18n.locales.find((locale) => path.endsWith(`/${locale}`))
|
||||
return lang ? path.slice(0, -lang.length - 1) : path
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user