seo/sitemap #18

Merged
GauthierWebDev merged 7 commits from seo/sitemap into main 2025-04-22 11:26:38 +00:00
2 changed files with 48 additions and 23 deletions
Showing only changes of commit d02c083898 - Show all commits

View File

@ -37,7 +37,7 @@ QuickLinks.QuickLink = (props: QuickLinkProps) => (
<div class="relative overflow-hidden rounded-xl p-6"> <div class="relative overflow-hidden rounded-xl p-6">
<Icon icon={props.icon} color="blue" class="h-8 w-8" /> <Icon icon={props.icon} color="blue" class="h-8 w-8" />
<h2 class="mt-4 font-display text-base text-slate-900"> <h2 class="mt-4 font-display text-base text-slate-900 leading-5">
<Link href={props.href}> <Link href={props.href}>
<span class="absolute -inset-px rounded-xl" /> <span class="absolute -inset-px rounded-xl" />
{props.title} {props.title}
@ -45,7 +45,7 @@ QuickLinks.QuickLink = (props: QuickLinkProps) => (
</h2> </h2>
{props.lastEdited && ( {props.lastEdited && (
<p class="-mt-2 italic mb-2 text-xs text-slate-500"> <p class="mt-2 mb-4 italic text-xs text-slate-500">
<span class="font-semibold">Dernière modification :</span>{" "} <span class="font-semibold">Dernière modification :</span>{" "}
<time datetime={props.lastEdited.toISOString()}> <time datetime={props.lastEdited.toISOString()}>
{props.lastEdited.toLocaleDateString("fr-FR", { {props.lastEdited.toLocaleDateString("fr-FR", {

View File

@ -230,30 +230,55 @@ class DocCache {
...customConfig, ...customConfig,
}; };
const sortedDocs = Array.from(this.cache.values()) const checkIfIncludedBasePath = (doc: SectionCache) => {
.sort((a, b) => b.lastEdit.getTime() - a.lastEdit.getTime())
.filter((doc) => {
if (config.includedBasePaths.length > 0) { if (config.includedBasePaths.length > 0) {
return config.includedBasePaths.some((basePath) => { return config.includedBasePaths.some((basePath) => {
return doc.filePath.startsWith(basePath); return doc.filePath.startsWith(basePath);
}); });
} }
return true;
};
const checkIfExcludedBasePaths = (doc: SectionCache) => {
if (config.excludedBasePaths.length > 0) { if (config.excludedBasePaths.length > 0) {
return !config.excludedBasePaths.some((basePath) => { return !config.excludedBasePaths.some((basePath) => {
return doc.filePath.startsWith(basePath); return doc.filePath.startsWith(basePath);
}); });
} }
return true;
};
const checkIfIncludedFileNames = (doc: SectionCache) => {
if (config.includedFileNames.length > 0) { if (config.includedFileNames.length > 0) {
return config.includedFileNames.some((fileName) => { return config.includedFileNames.some((fileName) => {
return doc.filePath.includes(fileName); return doc.filePath.includes(fileName);
}); });
} }
return true;
};
const checkIfExcludedFileNames = (doc: SectionCache) => {
if (config.excludedFileNames.length > 0) { if (config.excludedFileNames.length > 0) {
return !config.excludedFileNames.some((fileName) => { return !config.excludedFileNames.some((fileName) => {
return doc.filePath.includes(fileName); return doc.filePath.includes(fileName);
}); });
} }
return true; return true;
};
const sortedDocs = Array.from(this.cache.values())
.sort((a, b) => b.lastEdit.getTime() - a.lastEdit.getTime())
.filter((doc) => {
return [
checkIfIncludedBasePath(doc),
checkIfExcludedBasePaths(doc),
checkIfIncludedFileNames(doc),
checkIfExcludedFileNames(doc),
].every((check) => check === true);
}); });
if (config.limit > 0) return sortedDocs.slice(0, config.limit); if (config.limit > 0) return sortedDocs.slice(0, config.limit);