@farming-labs/next 0.0.9 → 0.0.11
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.
package/dist/config.mjs
CHANGED
|
@@ -33,10 +33,13 @@ import type { MDXComponents } from "mdx/types";
|
|
|
33
33
|
import docsConfig from "@/docs.config";
|
|
34
34
|
|
|
35
35
|
export function useMDXComponents(components?: MDXComponents): MDXComponents {
|
|
36
|
-
return getMDXComponents(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
return getMDXComponents(
|
|
37
|
+
{
|
|
38
|
+
...(docsConfig.components as MDXComponents),
|
|
39
|
+
...components,
|
|
40
|
+
},
|
|
41
|
+
{ onCopyClick: docsConfig.onCopyClick },
|
|
42
|
+
);
|
|
40
43
|
}
|
|
41
44
|
`;
|
|
42
45
|
const DOCS_LAYOUT_TEMPLATE = `\
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* Runs between remark-frontmatter and remark-mdx-frontmatter.
|
|
6
6
|
* Reads title/description from the YAML node and appends openGraph + twitter
|
|
7
7
|
* fields so that remark-mdx-frontmatter exports them as part of `metadata`.
|
|
8
|
+
*
|
|
9
|
+
* Skips injection when frontmatter already has `openGraph:` or `ogImage:`, so
|
|
10
|
+
* pages can use static OG images from frontmatter instead of the dynamic endpoint.
|
|
8
11
|
*/
|
|
9
12
|
interface RemarkOgOptions {
|
|
10
13
|
endpoint?: string;
|
|
@@ -4,11 +4,16 @@ function extractField(yaml, key) {
|
|
|
4
4
|
const m = yaml.match(re);
|
|
5
5
|
return m?.[1] ?? m?.[2] ?? m?.[3];
|
|
6
6
|
}
|
|
7
|
+
/** True if the YAML already defines openGraph or ogImage (static OG). */
|
|
8
|
+
function hasStaticOg(yaml) {
|
|
9
|
+
return /^\s*openGraph\s*:/m.test(yaml) || /^\s*ogImage\s*:/m.test(yaml);
|
|
10
|
+
}
|
|
7
11
|
function remarkOg(options = {}) {
|
|
8
12
|
const { endpoint = "/api/og" } = options;
|
|
9
13
|
return (tree) => {
|
|
10
14
|
const yamlNode = tree.children.find((n) => n.type === "yaml");
|
|
11
15
|
if (!yamlNode) return;
|
|
16
|
+
if (hasStaticOg(yamlNode.value)) return;
|
|
12
17
|
const title = extractField(yamlNode.value, "title");
|
|
13
18
|
if (!title) return;
|
|
14
19
|
const description = extractField(yamlNode.value, "description");
|