Coder Social home page Coder Social logo

astro-backlinks's Introduction

astro-backlinks

Reproduction of error getting the astro object after await import.meta.glob('../pages/seeds/*.md')

Problem:

after upgrading from v21 to v1.0.0-x In a project where I am using backlinks for a Digital Garden

Previously I could do // import all the md pages with meta.glob to prevent infinity loop if I import from the same page

const allSeeds = await import.meta.glob('../pages/garden/seeds/*.md')
let seeds = await Promise.all(
    Object.entries(allSeeds).map(([key, seed]) => {
        const url = key.replace('../pages/garden/seeds/', '/garden/seeds').replace('.md', '/')
        return seed().then(content => ({
            ...content.frontmatter,
            url
        }))
    })
)

seeds = seeds.filter(seed => {
    // compare the contant to see the pages my current seed is mentioned in
    return seed.astro.source.toLowerCase().includes(content.title.toLowerCase())
});

After the upgrade astro.source seems no longer available in the frontmatter how can I get the content now? Thanks in advance.

Solution:

The object received had an async function called default that returns the object that was provided in the previous version.

{
  /** Frontmatter from a blog post
  "title": "Astro 0.18 Release",
  "date": "Tuesday, July 27 2021",
  "author": "Matthew Phillips",
  "description": "Astro 0.18 is our biggest release since Astro launch.",
  "draft": false,
  "keywords": ["astro", "release", "announcement"]
  **/
  "astro": {
    "headers": [
      {
        "depth": 1,
        "text": "Astro 0.18 Release",
        "slug": "astro-018-release"
      },
      {
        "depth": 2,
        "text": "Responsive partial hydration",
        "slug": "responsive-partial-hydration"
      }
      /* ... */
    ],
    "source": "# Astro 0.18 Release\nA little over a month ago, the first public beta [...]"
  },
  "url": ""
}

Edit on StackBlitz ⚡️

astro-backlinks's People

Contributors

jesusantguerrero avatar

Watchers

 avatar

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.