I'll create a tool that fetches and displays website metadata in a card format when you enter a domain address. The card will show the website's OG image as a thumbnail, favicon as a logo, and include the title and description from the metadata.
Metadata Fetching: When you click "Generate Card", the app:
Extracts metadata including:
<title>
tagCard Display: The metadata is displayed in a card format showing:
You can use this tool to quickly preview how websites appear in social media shares or to create a collection of website cards for bookmarking purposes.
I see the issue. The error "Unexpected identifier '$'" is likely coming from the JSDOM library usage in the server action. Let's fix this by using a different approach to parse HTML that's more compatible with Next.js.
I've fixed the error by replacing the JSDOM-based approach with a simpler regex-based solution. The "Unexpected identifier '$'" error was likely caused by the JSDOM library, which might not be properly supported in the Next.js server environment.
Created separate extraction functions:
extractTitle()
- Gets the website titleextractDescription()
- Gets the meta descriptionextractOgImage()
- Gets the Open Graph imageextractFavicon()
- Gets the faviconresolveUrl()
function remains the same to handle relative URLs.This approach should be more compatible with Next.js server components and server actions. The regex patterns will extract the same metadata as before, but without relying on DOM manipulation libraries that might cause issues in the server environment.
Try this updated version - it should resolve the "Unexpected identifier '$'" error while maintaining all the functionality of the original implementation.