HiDeoo/starlight-obsidian

Bug : copyStarlightFrontmatter only works for the first note ?

Closed this issue · 2 comments

Hi,

Describe the bug

I don’t understand why, but copyStarlightFrontmatter: true in my astro.config.mjs doesn’t work for every notes, but only for one of my obsidian notes.

It’s a bit frustrating because I can’t use some useful starlight features like sorting the notes via the frontmatter and such

To Reproduce

Here is my astro.config.mjs file :

import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
import starlightObsidian, { obsidianSidebarGroup } from 'starlight-obsidian'
import starlightLinksValidator from 'starlight-links-validator'
import starlightImageZoom from 'starlight-image-zoom'

export default defineConfig({
  integrations: [
    starlight({
      plugins: [
        // Generate the Obsidian vault pages.
        starlightObsidian({
		      // Configuration options go here.
          vault: 'D:/Documents/TSSR/Cours TSSR/',
          // label: 'Cours',
          skipGeneration: !!process.env['CI'] || !!process.env['VERCEL'],
          copyStarlightFrontmatter: true,
          ignore: [
            // Ignore all files and folders in the `private` folder.
            '_private/**/*',
            // Ignore all files containing `secret` in their name.
            // '**/*secret*',
          ],
        }),
        starlightImageZoom(),
        starlightLinksValidator({
          // Configuration options go here.
        }),
      ],
      sidebar: [
        // Add the generated sidebar group to the sidebar.
        obsidianSidebarGroup,
      ],
      title: 'Ma documentation TSSR',
    }),
  ],
})

Here is the original front matter of one of my note :

---
title: TP3
aliases: 
date: 2024-05-30
tags:
  - TSSR
  - TP
description: Documentation sur TP3
publish: false
permalink:
---

And starlight obsidian still strip it :

---
title: TP3
editUrl: false
---

The weird thing is that this note is not stripped, so it works with starlight features : https://github.com/alype/TSSR-doc/blob/main/src/content/docs/notes/R%C3%A9seaux/Mod%C3%A8le%20OSI.md?plain=1

Expected behavior

The copyStarlightFrontmatter: true option should work on all the notes of the vault

How often does this bug happen?

Every time

System Info

OS : Windows 10 22H2


Anyways, thanks for this plugin, it helps a lot !

Thanks for your feedback 🙌

This should now be fixed in version 0.4.6 that I just released.

The issue was actually due to Obsidian frontmatter potentially including null values (e.g. aliases or permalink in your example) which prevented to properly parse the frontmatter.

In the example you provided, the note should now be entirely skipped due to publish: false.

amazing, it works now after the update, many thanks ✨