Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated wallet #103

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 51 additions & 49 deletions src/app/wallets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
// src/app/wallets/page.tsx
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState } from "react";
import Image from "next/image";
import { getFileContent, getRoot } from '@/lib/authAndFetch'
import { getBanner } from '@/lib/helpers'
import { parseMarkdown } from '@/lib/parseMarkdown';
import WalletList from '@/components/WalletList';
import { genMetadata } from '@/lib/helpers';
import { Metadata } from 'next';
import { getFileContent, getRoot } from "@/lib/authAndFetch";
import { getBanner } from "@/lib/helpers";
import { parseMarkdown } from "@/lib/parseMarkdown";
import WalletList from "@/components/WalletList";
import { genMetadata } from "@/lib/helpers";
import { Metadata } from "next";

const imgUrl = getBanner(`using-zcash`)
const imgUrl = getBanner(`using-zcash`);

export const metadata: Metadata = genMetadata({
title: "Wallets",
url: "https://zechub.wiki/wallets",
image: imgUrl,
})
title: "Wallets",
url: "https://zechub.wiki/wallets",
image: imgUrl,
});

export default async function Page({ params }: { params: { slug: string } }) {

const { slug } = params
const url = `/site/Using_Zcash/Wallets.md`

const markdown = await getFileContent(url)

const content = markdown ? markdown : 'No Data or Wrong file'
const urlRoot = `/site/using-zcash`
const roots = await getRoot(urlRoot)


const walletsParsed = parseMarkdown(content);
// console.log("Parsed Wallets:", walletsParsed); // Check parsed markdown output

return (

<main>
<div className='flex justify-center w-full mb-5 bg-transparent rounded pb-4'>
<Image
className="w-full mb-5 object-cover "
alt="wiki-banner"
width={800}
height={50}
src={imgUrl != undefined ? imgUrl : '/wiki-banner.avif'}
/>
</div>

<div id="content" className={`flex flex-col space-y-5 ${roots && roots.length > 0 ? 'md:flex-row md:space-x-5' : 'md:flex-col'} h-auto w-full py-5`}>
<section className='h-auto w-full'>
<div>
<WalletList allWallets={walletsParsed} />
</div>
</section>
</div>
</main>
)
}
const { slug } = params;
const url = `/site/Using_Zcash/Wallets.md`;

const markdown = await getFileContent(url);

const content = markdown ? markdown : "No Data or Wrong file";
const urlRoot = `/site/using-zcash`;
const roots = await getRoot(urlRoot);

const walletsParsed = parseMarkdown(content);
// console.log("Parsed Wallets:", walletsParsed); // Check parsed markdown output

return (
<main>
<div className="flex justify-center w-full mb-5 bg-transparent rounded pb-4">
<Image
className="w-full mb-5 object-cover "
alt="wiki-banner"
width={800}
height={50}
src={imgUrl != undefined ? imgUrl : "/wiki-banner.avif"}
/>
</div>

<div
id="content"
className={`flex flex-col space-y-5 ${
roots && roots.length > 0 ? "md:flex-row md:space-x-5" : "md:flex-col"
} h-auto w-full py-5`}
>
<section className="h-auto w-full">
<div>
<WalletList allWallets={walletsParsed} />
</div>
</section>
</div>
</main>
);
}
2 changes: 1 addition & 1 deletion src/components/WalletList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const WalletList: React.FC<Props> = ({ allWallets }) => {
);

const sortedWallets = filteredWallets.sort((a, b) => likes[b.title] - likes[a.title]);

return (
<div className="flex flex-col w-full md:flex-row">
<div className="wallet-filter w-auto md:w-[30%] relative">
Expand Down
8 changes: 4 additions & 4 deletions src/lib/parseMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export function parseMarkdown(md: string) {
const lines = section.trim().split("\n");
const titleMatch = lines[0]?.match(/## \[(.*?)\]\((.*?)\)/);
const imageUrlMatch = lines[1]?.match(/!\[logo\]\((.*?) ".*?"\)/);
const devices = lines[2]?.split(": ")[1]?.split(" | ").map(item => item.trim());
const pools = lines[3]?.split(": ")[1]?.split(" | ").map(item => item.trim());
const features = lines[4]?.split(": ")[1]?.split(" | ").map(item => item.trim());
const devices = lines[2]?.split(": ")[1]?.split(" | ").map(item => item.trim()) || [];
const pools = lines[3]?.split(": ")[1]?.split(" | ").map(item => item.trim()) || [];
const features = lines[4]?.split(": ")[1]?.split(" | ").map(item => item.trim()) || [];
const syncSpeed = lines[5]?.match(/!\[syncspeed\]\((.*?) ".*?"\)/);

return {
Expand All @@ -16,7 +16,7 @@ export function parseMarkdown(md: string) {
devices,
pools,
features,
syncSpeed :syncSpeed ? syncSpeed[1] : '',
syncSpeed : syncSpeed ? syncSpeed[1] : '',
};
});

Expand Down
Loading