@pas7/llm-seo 0.2.0 → 0.3.0
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/README.md +2 -0
- package/dist/adapters/index.d.ts +3 -2
- package/dist/adapters/index.js +351 -12
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/next/index.d.ts +67 -2
- package/dist/adapters/next/index.js +351 -12
- package/dist/adapters/next/index.js.map +1 -1
- package/dist/canonical-from-manifest-BKpEmouS.d.ts +109 -0
- package/dist/cli/bin.js +58 -2
- package/dist/cli/bin.js.map +1 -1
- package/dist/{config.schema-Dj2VTdnD.d.ts → config.schema-CI5OBbhQ.d.ts} +382 -2
- package/dist/core/index.d.ts +4 -110
- package/dist/index.d.ts +4 -4
- package/dist/index.js +127 -1
- package/dist/index.js.map +1 -1
- package/dist/schema/index.d.ts +2 -3
- package/package.json +1 -1
- package/dist/manifest.schema-B_z3rxRV.d.ts +0 -384
package/dist/index.js
CHANGED
|
@@ -1828,6 +1828,132 @@ function fromNextContentManifest(manifest, options = {}) {
|
|
|
1828
1828
|
return result;
|
|
1829
1829
|
});
|
|
1830
1830
|
}
|
|
1831
|
+
function createSectionManifest(options) {
|
|
1832
|
+
const {
|
|
1833
|
+
items,
|
|
1834
|
+
sectionName,
|
|
1835
|
+
sectionPath,
|
|
1836
|
+
routeStyle,
|
|
1837
|
+
defaultLocale,
|
|
1838
|
+
defaultLocaleOverride,
|
|
1839
|
+
pathnameFor,
|
|
1840
|
+
slugKey = "slug",
|
|
1841
|
+
localesKey = "locales",
|
|
1842
|
+
updatedAtKey = "updatedAt",
|
|
1843
|
+
publishedAtKey = "publishedAt",
|
|
1844
|
+
priorityKey = "priority",
|
|
1845
|
+
canonicalOverrideKey = "canonicalOverride",
|
|
1846
|
+
titleFrom = "title",
|
|
1847
|
+
descriptionFrom = "description"
|
|
1848
|
+
} = options;
|
|
1849
|
+
const normalizedItems = items.map((item) => {
|
|
1850
|
+
const rawSlug = readStringField(item, slugKey);
|
|
1851
|
+
if (!rawSlug) {
|
|
1852
|
+
return null;
|
|
1853
|
+
}
|
|
1854
|
+
const normalized = {
|
|
1855
|
+
slug: rawSlug.startsWith("/") ? rawSlug : `/${rawSlug}`
|
|
1856
|
+
};
|
|
1857
|
+
const locales = readStringArrayField(item, localesKey);
|
|
1858
|
+
if (locales.length > 0) {
|
|
1859
|
+
normalized.locales = locales;
|
|
1860
|
+
} else if (defaultLocale) {
|
|
1861
|
+
normalized.locales = [defaultLocale];
|
|
1862
|
+
}
|
|
1863
|
+
const updatedAt = readStringField(item, updatedAtKey);
|
|
1864
|
+
if (updatedAt) {
|
|
1865
|
+
normalized.updatedAt = updatedAt;
|
|
1866
|
+
}
|
|
1867
|
+
const publishedAt = readStringField(item, publishedAtKey);
|
|
1868
|
+
if (publishedAt) {
|
|
1869
|
+
normalized.publishedAt = publishedAt;
|
|
1870
|
+
}
|
|
1871
|
+
const priority = readNumberField(item, priorityKey);
|
|
1872
|
+
if (priority !== void 0) {
|
|
1873
|
+
normalized.priority = priority;
|
|
1874
|
+
}
|
|
1875
|
+
const canonicalOverride = readStringField(item, canonicalOverrideKey);
|
|
1876
|
+
if (canonicalOverride) {
|
|
1877
|
+
normalized.canonicalOverride = canonicalOverride;
|
|
1878
|
+
}
|
|
1879
|
+
const title = readMappedString(item, titleFrom);
|
|
1880
|
+
if (title) {
|
|
1881
|
+
normalized.title = title;
|
|
1882
|
+
}
|
|
1883
|
+
const description = readMappedString(item, descriptionFrom);
|
|
1884
|
+
if (description) {
|
|
1885
|
+
normalized.description = description;
|
|
1886
|
+
}
|
|
1887
|
+
return normalized;
|
|
1888
|
+
}).filter((item) => item !== null);
|
|
1889
|
+
const sortedItems = sortBy(normalizedItems, (item) => {
|
|
1890
|
+
const locales = item.locales?.join(",") ?? "";
|
|
1891
|
+
return `${item.slug}|${locales}`;
|
|
1892
|
+
});
|
|
1893
|
+
return {
|
|
1894
|
+
items: sortedItems,
|
|
1895
|
+
...sectionName && { sectionName },
|
|
1896
|
+
...sectionPath && { sectionPath },
|
|
1897
|
+
...routeStyle && { routeStyle },
|
|
1898
|
+
...defaultLocaleOverride && { defaultLocaleOverride },
|
|
1899
|
+
...pathnameFor && { pathnameFor }
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1902
|
+
function applySectionCanonicalOverrides(options) {
|
|
1903
|
+
const {
|
|
1904
|
+
section,
|
|
1905
|
+
baseUrl,
|
|
1906
|
+
defaultLocale,
|
|
1907
|
+
trailingSlash = "never",
|
|
1908
|
+
localeStrategy = "prefix"
|
|
1909
|
+
} = options;
|
|
1910
|
+
const mappedItems = section.items.map((item) => {
|
|
1911
|
+
const canonicalOptions = {
|
|
1912
|
+
baseUrl,
|
|
1913
|
+
defaultLocale: section.defaultLocaleOverride ?? defaultLocale,
|
|
1914
|
+
trailingSlash,
|
|
1915
|
+
localeStrategy,
|
|
1916
|
+
...section.routeStyle && { routeStyle: section.routeStyle },
|
|
1917
|
+
...section.sectionPath && {
|
|
1918
|
+
sectionPath: section.sectionPath,
|
|
1919
|
+
routePrefix: section.sectionPath
|
|
1920
|
+
},
|
|
1921
|
+
...section.sectionName && { sectionName: section.sectionName },
|
|
1922
|
+
...section.pathnameFor && { pathnameFor: section.pathnameFor }
|
|
1923
|
+
};
|
|
1924
|
+
const canonicalOverride = createCanonicalUrlForItem(item, canonicalOptions);
|
|
1925
|
+
return {
|
|
1926
|
+
...item,
|
|
1927
|
+
canonicalOverride
|
|
1928
|
+
};
|
|
1929
|
+
});
|
|
1930
|
+
return {
|
|
1931
|
+
...section,
|
|
1932
|
+
items: mappedItems
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
function readStringField(item, key) {
|
|
1936
|
+
const value = item[key];
|
|
1937
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
1938
|
+
}
|
|
1939
|
+
function readNumberField(item, key) {
|
|
1940
|
+
const value = item[key];
|
|
1941
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1942
|
+
}
|
|
1943
|
+
function readStringArrayField(item, key) {
|
|
1944
|
+
const value = item[key];
|
|
1945
|
+
if (!Array.isArray(value)) {
|
|
1946
|
+
return [];
|
|
1947
|
+
}
|
|
1948
|
+
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
1949
|
+
}
|
|
1950
|
+
function readMappedString(item, mapper) {
|
|
1951
|
+
if (typeof mapper === "function") {
|
|
1952
|
+
const value = mapper(item);
|
|
1953
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
1954
|
+
}
|
|
1955
|
+
return readStringField(item, mapper);
|
|
1956
|
+
}
|
|
1831
1957
|
function parseFrontmatter(content) {
|
|
1832
1958
|
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
1833
1959
|
const match = content.match(frontmatterRegex);
|
|
@@ -2115,6 +2241,6 @@ function createNextPlugin() {
|
|
|
2115
2241
|
};
|
|
2116
2242
|
}
|
|
2117
2243
|
|
|
2118
|
-
export { BuildManifestSchema, CheckConfigSchema, ConfigSchema, DEFAULT_CHECKER_CONFIG, FullConfigSchema, LINT_RULES, ManifestConfigValueSchema, ManifestSectionConfigSchema, ManifestsConfigSchema2 as ManifestsConfigSchema, OptionalSectionSchema, PageManifestSchema, RouteStyleSchema, SiteManifestSchema, checkFileExists, checkFilesAgainstExpected, checkGeneratedFiles, checkManifest, citationToJsonLd, citationToMarkdown, compareContent, compareStrings, createCanonicalBundleFromConfig, createCanonicalUrlForItem, createCanonicalUrlsFromManifest, createCitation, createCitationsJson, createCitationsJsonString, createIssue, createLlmsFullTxt, createLlmsTxt, createManifestFromData, createManifestFromPagesDir, createNextConfig, createNextPlugin, createRobotsLlmsPolicySnippet, dedupeUrls, extractCanonicalUrls, extractLocaleFromPath, extractPagePaths, filterBySeverity, formatValidationErrors, fromNextContentManifest, generateAlternateUrls, generateBuildScripts, generateCanonicalUrl, generateLlmsFullTxt, generateLlmsTxt, generateNextManifest, generatePageContent, generateReferenceList, groupByPage, groupBySeverity, lintContent, localizePath, normalizeLineEndings, normalizeLineWhitespace, normalizeSeoText, normalizeUrl, normalizeWhitespace, postBuildHook, readFileContent, resolveManifestSections, sortBy, sortStrings, sortUrls, validate, validateOrThrow };
|
|
2244
|
+
export { BuildManifestSchema, CheckConfigSchema, ConfigSchema, DEFAULT_CHECKER_CONFIG, FullConfigSchema, LINT_RULES, ManifestConfigValueSchema, ManifestSectionConfigSchema, ManifestsConfigSchema2 as ManifestsConfigSchema, OptionalSectionSchema, PageManifestSchema, RouteStyleSchema, SiteManifestSchema, applySectionCanonicalOverrides, checkFileExists, checkFilesAgainstExpected, checkGeneratedFiles, checkManifest, citationToJsonLd, citationToMarkdown, compareContent, compareStrings, createCanonicalBundleFromConfig, createCanonicalUrlForItem, createCanonicalUrlsFromManifest, createCitation, createCitationsJson, createCitationsJsonString, createIssue, createLlmsFullTxt, createLlmsTxt, createManifestFromData, createManifestFromPagesDir, createNextConfig, createNextPlugin, createRobotsLlmsPolicySnippet, createSectionManifest, dedupeUrls, extractCanonicalUrls, extractLocaleFromPath, extractPagePaths, filterBySeverity, formatValidationErrors, fromNextContentManifest, generateAlternateUrls, generateBuildScripts, generateCanonicalUrl, generateLlmsFullTxt, generateLlmsTxt, generateNextManifest, generatePageContent, generateReferenceList, groupByPage, groupBySeverity, lintContent, localizePath, normalizeLineEndings, normalizeLineWhitespace, normalizeSeoText, normalizeUrl, normalizeWhitespace, postBuildHook, readFileContent, resolveManifestSections, sortBy, sortStrings, sortUrls, validate, validateOrThrow };
|
|
2119
2245
|
//# sourceMappingURL=index.js.map
|
|
2120
2246
|
//# sourceMappingURL=index.js.map
|