extract-from-sitemap 0.0.24 → 0.0.25

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.
Files changed (2) hide show
  1. package/mod.js +14 -3
  2. package/package.json +1 -1
package/mod.js CHANGED
@@ -640,6 +640,7 @@ export async function processLLMTextConfig(config, apiKey) {
640
640
  config.title,
641
641
  config.description,
642
642
  config.details,
643
+ config.origin,
643
644
  allSources,
644
645
  );
645
646
 
@@ -662,11 +663,18 @@ export async function processLLMTextConfig(config, apiKey) {
662
663
  * Generate combined llms.txt from all sources
663
664
  * @param {string} title - Top-level title
664
665
  * @param {string} description - Top-level description
665
- * @param {string} [details] - Optional top-level details
666
+ * @param {string} details - top-level details
667
+ * @param {string} origin - origin for all links
666
668
  * @param {ProcessedSource[]} allSources - All processed sources
667
669
  * @returns {string} Combined llms.txt content
668
670
  */
669
- function generateCombinedLlmsTxt(title, description, details, allSources) {
671
+ function generateCombinedLlmsTxt(
672
+ title,
673
+ description,
674
+ details,
675
+ origin,
676
+ allSources,
677
+ ) {
670
678
  let combinedTxt = `# ${title}\n\n> ${description}\n\n`;
671
679
 
672
680
  if (details) {
@@ -693,7 +701,10 @@ function generateCombinedLlmsTxt(title, description, details, allSources) {
693
701
  if (source.keepOriginalUrls) {
694
702
  link = file.originalUrl;
695
703
  } else {
696
- link = source.pathPrefix + (path.startsWith("/") ? path : "/" + path);
704
+ link = [origin, source.pathPrefix, path]
705
+ .map((chunk) => (chunk.startsWith("/") ? chunk.slice(1) : chunk))
706
+ .map((chunk) => (chunk.endsWith("/") ? chunk.slice(-1) : chunk))
707
+ .join("/");
697
708
  }
698
709
 
699
710
  combinedTxt += `- [${title}](${link})${description}\n`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "extract-from-sitemap",
3
3
  "bin": "cli.js",
4
- "version": "0.0.24",
4
+ "version": "0.0.25",
5
5
  "main": "mod.js",
6
6
  "description": "A module and CLI that allows extracting all pages from a sitemap into markdown and a llms.txt, using Parallel.ai APIs.",
7
7
  "files": [