feat: enhance date formatting in changelog
Build & Push Docker Image / build (push) Has been cancelled
Build & Push Docker Image / build (push) Has been cancelled
- Added support for Latin digit formatting in release dates to improve readability. - Updated the ChangelogVersionCard component to ensure proper text direction for dates.
This commit is contained in:
+37
-9
@@ -136,18 +136,46 @@ export async function getPosts(
|
||||
return { posts, total, totalPages };
|
||||
}
|
||||
|
||||
export async function getPostBySlug(slug: string): Promise<WpPost | null> {
|
||||
const decodedSlug = decodeURIComponent(slug);
|
||||
const params = new URLSearchParams({ slug: decodedSlug, _embed: "1" });
|
||||
const url = `${WP_API_BASE}/posts?${params.toString()}`;
|
||||
const res = await fetchWithTimeout(url);
|
||||
/** وردپرس گاهی slug را بهصورت percent-encoded ذخیره میکند؛ مسیر ممکن است چندبار encode شده باشد. */
|
||||
export function normalizeBlogSlug(slug: string): string[] {
|
||||
const variants: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
let current = slug.trim();
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`WP API error: ${res.status} ${res.statusText}`);
|
||||
for (let i = 0; i < 4 && current; i++) {
|
||||
if (!seen.has(current)) {
|
||||
seen.add(current);
|
||||
variants.push(current);
|
||||
}
|
||||
try {
|
||||
const decoded = decodeURIComponent(current);
|
||||
if (decoded === current) break;
|
||||
current = decoded;
|
||||
} catch {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const posts: WpPost[] = await res.json();
|
||||
return posts.length > 0 ? posts[0] : null;
|
||||
return variants;
|
||||
}
|
||||
|
||||
export async function getPostBySlug(slug: string): Promise<WpPost | null> {
|
||||
const slugVariants = normalizeBlogSlug(slug);
|
||||
|
||||
for (const slugVariant of slugVariants) {
|
||||
const params = new URLSearchParams({ slug: slugVariant, _embed: "1" });
|
||||
const url = `${WP_API_BASE}/posts?${params.toString()}`;
|
||||
const res = await fetchWithTimeout(url);
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`WP API error: ${res.status} ${res.statusText}`);
|
||||
}
|
||||
|
||||
const posts: WpPost[] = await res.json();
|
||||
if (posts.length > 0) return posts[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function getRelatedPosts(
|
||||
|
||||
Reference in New Issue
Block a user