53 - garden-astro - Add link resolver

Create a link resolver script and hook with Github fetch integration & dev.ts script. It uses gray-matter to read each of the entries and check if each markdown link points to other web pages (after filter non-published pages), then overwrite the link with working slugs.

  • Link to other published page should work
  • Link to homepage should work on website (not working on Obsidian since it does not link to a file)
  • Link to other websites should still work since it starts with http

#offstream I also added Prettier & ESLint, then took some time to add “View Source” button, to achieve that I have to create another script to add filepath: key to frontmatter

import fs from "node:fs"
import { remark } from "remark"
import { visit } from "unist-util-visit"
import remarkFrontmatter from "remark-frontmatter"

export const addFilepath = (filePath: string) => {
  const markdown = fs.readFileSync(filePath, "utf-8")

  const processor = remark()
    .use(() => (tree, file) => {
      visit(tree, "root", (node) => {
        visit(node, "yaml", (yamlNode) => {
          yamlNode.value += `\nfilepath: ${filePath}`

  const result = processor.processSync(markdown)

  fs.writeFileSync(filePath, String(result), {
    encoding: "utf-8",