Giter Site home page Giter Site logo

Incorrect metadata types about metascraper HOT 4 CLOSED

JaneJeon avatar JaneJeon commented on August 31, 2024
Incorrect metadata types

from metascraper.

Comments (4)

JaneJeon avatar JaneJeon commented on August 31, 2024

Oh, lang is missing as well (from metascraper-lang)

from metascraper.

Kikobeats avatar Kikobeats commented on August 31, 2024

@JaneJeon I will accept a PR fixing this 🙏

from metascraper.

JaneJeon avatar JaneJeon commented on August 31, 2024

What is the preferred way to resolve this? Just make the output contain every single possible type and make it nullable (and optional)? Or somehow compose types package by package?

(I have no idea how you would go about approach 2 - my typescript-fu is too weak)

from metascraper.

Kikobeats avatar Kikobeats commented on August 31, 2024

Any rule can return string/number/whatever but also null; null means the value isn't being resolved: https://github.com/microlinkhq/metascraper/blob/master/packages/metascraper/src/get-data.js#L6

I think it could be as simple as:

interface Metadata {
  author: string | null;
  date: string | null;
  description: string | null;
  image: string | null;
  publisher: string | null;
  title: string | null;
  url: string | null;
}

About why lang is missing, it's tricky because every property has its package. The lang will be present if metascraper-lang is is loaded.

What could be nice is to add every property added by any metascraper package with a little description, such as:

interface Metadata {
  /* Get lang property from HTML markup. It will be present when `metascraper-lang` is required */
  lang: string | null
}

from metascraper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.