- Takes the meta from the link parameter and automatically generates an
.md
content file in the appropriate format for Resurse.dev.
npm i https://github.com/pgabriel02/resource-importer
Then import the helper function in your project:
import generateResourceFileWithMetadata from 'resource-importer'
Then use it when appropriate:
use await generateResourceFileWithMetadata(url);
import { getCollection } from 'astro:content'
import { generateResourceFileWithMetadata } from 'resource-importer'
async function test() {
const config = await getCollection('resources')
await generateResourceFileWithMetadata({
url: 'https://www.youtube.com/watch?v=nm2wIUr5KNk',
contentKey: 'resources',
configData: config,
elementsToBeEdited: {
title: 'title',
url: 'url',
imageUrl: 'banner',
imageAlt: 'title'
}
})
}
test()
import generateResourceFileWithMetadata from 'resource-importer'
await generateResourceFileWithMetadata('https://www.youtube.com/watch?v=nzSsv9c_ynQ&t=7503s&ab_channel=ViorelMocanu')
Will output these files: