@farming-labs/next 0.1.29 → 0.1.32
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 +79 -13
- package/package.json +3 -3
package/dist/config.mjs
CHANGED
|
@@ -147,7 +147,21 @@ const FILE_EXTS = [
|
|
|
147
147
|
const INTERNAL_DOCS_CONFIG_ALIAS = "@farming-labs/next-internal-docs-config";
|
|
148
148
|
const NEXT_PACKAGE_ROOT = fileURLToPath(new URL("..", import.meta.url));
|
|
149
149
|
const DEFAULT_AGENT_SPEC_ROUTE = "/api/docs/agent/spec";
|
|
150
|
+
const DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE = "/.well-known/agent";
|
|
151
|
+
const DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE = "/.well-known/agent.json";
|
|
150
152
|
const DEFAULT_AGENT_FEEDBACK_ROUTE = "/api/docs/agent/feedback";
|
|
153
|
+
const DEFAULT_LLMS_TXT_ROUTE = "/llms.txt";
|
|
154
|
+
const DEFAULT_LLMS_FULL_TXT_ROUTE = "/llms-full.txt";
|
|
155
|
+
const DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE = "/.well-known/llms.txt";
|
|
156
|
+
const DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE = "/.well-known/llms-full.txt";
|
|
157
|
+
const MARKDOWN_ACCEPT_HEADER_VALUE = [
|
|
158
|
+
"(?:^|.*,\\s*)",
|
|
159
|
+
"text/markdown",
|
|
160
|
+
"(?:\\s*;",
|
|
161
|
+
"(?!\\s*(?:[^,;]*;\\s*)*q\\s*=\\s*(?:0+(?:\\.0*)?|\\.0+)\\s*(?:;|,|$))",
|
|
162
|
+
"[^,]*)?",
|
|
163
|
+
"(?:\\s*,.*|$)"
|
|
164
|
+
].join("");
|
|
151
165
|
function resolvePackageAlias(packageName, fallbacks = []) {
|
|
152
166
|
return [join(NEXT_PACKAGE_ROOT, "node_modules", packageName), ...fallbacks.map((value) => join(NEXT_PACKAGE_ROOT, value))].find((value) => existsSync(value));
|
|
153
167
|
}
|
|
@@ -695,19 +709,67 @@ function readAgentFeedbackConfig(root) {
|
|
|
695
709
|
}
|
|
696
710
|
function buildDocsMarkdownRewrites(entry) {
|
|
697
711
|
const normalizedEntry = entry.replace(/^\/+|\/+$/g, "") || "docs";
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
712
|
+
const markdownAcceptHeader = {
|
|
713
|
+
type: "header",
|
|
714
|
+
key: "accept",
|
|
715
|
+
value: MARKDOWN_ACCEPT_HEADER_VALUE
|
|
716
|
+
};
|
|
717
|
+
return [
|
|
718
|
+
{
|
|
719
|
+
source: `/${normalizedEntry}.md`,
|
|
720
|
+
destination: "/api/docs?format=markdown"
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
source: `/${normalizedEntry}/:slug*.md`,
|
|
724
|
+
destination: "/api/docs?format=markdown&path=:slug*"
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
source: `/${normalizedEntry}`,
|
|
728
|
+
has: [markdownAcceptHeader],
|
|
729
|
+
destination: "/api/docs?format=markdown"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
source: `/${normalizedEntry}/:slug*`,
|
|
733
|
+
has: [markdownAcceptHeader],
|
|
734
|
+
destination: "/api/docs?format=markdown&path=:slug*"
|
|
735
|
+
}
|
|
736
|
+
];
|
|
705
737
|
}
|
|
706
738
|
function buildAgentSpecRewrites() {
|
|
707
|
-
return [
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
739
|
+
return [
|
|
740
|
+
{
|
|
741
|
+
source: DEFAULT_AGENT_SPEC_ROUTE,
|
|
742
|
+
destination: "/api/docs?agent=spec"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
source: DEFAULT_AGENT_SPEC_WELL_KNOWN_ROUTE,
|
|
746
|
+
destination: "/api/docs?agent=spec"
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
source: DEFAULT_AGENT_SPEC_WELL_KNOWN_JSON_ROUTE,
|
|
750
|
+
destination: "/api/docs?agent=spec"
|
|
751
|
+
}
|
|
752
|
+
];
|
|
753
|
+
}
|
|
754
|
+
function buildLlmsTxtRewrites() {
|
|
755
|
+
return [
|
|
756
|
+
{
|
|
757
|
+
source: DEFAULT_LLMS_TXT_ROUTE,
|
|
758
|
+
destination: "/api/docs?format=llms"
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
source: DEFAULT_LLMS_FULL_TXT_ROUTE,
|
|
762
|
+
destination: "/api/docs?format=llms-full"
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
source: DEFAULT_LLMS_TXT_WELL_KNOWN_ROUTE,
|
|
766
|
+
destination: "/api/docs?format=llms"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
source: DEFAULT_LLMS_FULL_TXT_WELL_KNOWN_ROUTE,
|
|
770
|
+
destination: "/api/docs?format=llms-full"
|
|
771
|
+
}
|
|
772
|
+
];
|
|
711
773
|
}
|
|
712
774
|
function buildAgentFeedbackRewrites(config) {
|
|
713
775
|
if (!config.enabled) return [];
|
|
@@ -733,11 +795,15 @@ function dedupeRewrites(rewrites) {
|
|
|
733
795
|
function mergeDocsMarkdownRewrites(entry, agentFeedback, result) {
|
|
734
796
|
const autoRewrites = [
|
|
735
797
|
...buildAgentSpecRewrites(),
|
|
798
|
+
...buildLlmsTxtRewrites(),
|
|
736
799
|
...buildDocsMarkdownRewrites(entry),
|
|
737
800
|
...buildAgentFeedbackRewrites(agentFeedback)
|
|
738
801
|
];
|
|
739
|
-
if (!result) return
|
|
740
|
-
if (Array.isArray(result)) return
|
|
802
|
+
if (!result) return { beforeFiles: dedupeRewrites(autoRewrites) };
|
|
803
|
+
if (Array.isArray(result)) return {
|
|
804
|
+
beforeFiles: dedupeRewrites(autoRewrites),
|
|
805
|
+
afterFiles: result
|
|
806
|
+
};
|
|
741
807
|
return {
|
|
742
808
|
beforeFiles: dedupeRewrites([...autoRewrites, ...result.beforeFiles ?? []]),
|
|
743
809
|
afterFiles: result.afterFiles ?? [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"tsdown": "^0.20.3",
|
|
96
96
|
"typescript": "^5.9.3",
|
|
97
97
|
"vitest": "^3.2.4",
|
|
98
|
-
"@farming-labs/
|
|
99
|
-
"@farming-labs/
|
|
98
|
+
"@farming-labs/theme": "0.1.32",
|
|
99
|
+
"@farming-labs/docs": "0.1.32"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"@farming-labs/docs": ">=0.0.1",
|