Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ignores in all plugins more adaptable: Read from file / folder #8

Open
trueberryless opened this issue Jan 12, 2025 · 0 comments
Assignees
Labels
🚧 config Configuration file updates ⏫ enhancement New feature or request 🆘 help wanted Extra attention is needed 📦 package Updates in package structure or package.json
Milestone

Comments

@trueberryless
Copy link
Member

In larger documentation websites, like e.g. the Astro docs, it will be hard to maintain a list of strings in the astr.config.mjs file for the words that should be ignored by the different plugins.

I therefore recommend, implementing a more dynamic zod schema for all ignore fields, which can either be a list of words to ignore (z.array(z.string()).default([])) or a file path to a single file or folder (z.string().optional()). In case the string has a file extension, it can be assumed that this is a file, if it ends with / than we can assume, that in this folder there exist files with the locals, e.g.: en.md, fr.md, de.md.

We have to think about how we know the extensions of the files in the folder. Maybe just allow Markdown or support more extensions, like yaml...

This would lead to some kind of zod definition which looks like this:

/**
 * Defines a list of words that should be ignored by the spell checker.
 *
 * The words in this list will be ignored by the spell checker and will not be considered as misspelled.
 *
 * @default []
 */
ignore: z
  .union([
    z.array(z.string()),
    z.string().refine(
      (path) => {
        if (path.endsWith("/")) {
          return true;
        }
        const lastSegment = path.split("/").pop();
        return lastSegment?.includes(".") ?? false;
      },
      {
        message:
          "The string must either end with a '/' (indicating a folder) or include an extension (indicating a file).",
      }
    ),
  ])
  .default([]),

One difficult point is how to read the relative path of the file from the plugin. Therefore, I'll set the milestone to v0.2.0 as I think I rather wanna publish the v0.1 soon and can implement this logic later.

@trueberryless trueberryless added 🚧 config Configuration file updates ⏫ enhancement New feature or request 🆘 help wanted Extra attention is needed 📦 package Updates in package structure or package.json labels Jan 12, 2025
@trueberryless trueberryless added this to the 0.2.0 milestone Jan 12, 2025
@trueberryless trueberryless self-assigned this Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 config Configuration file updates ⏫ enhancement New feature or request 🆘 help wanted Extra attention is needed 📦 package Updates in package structure or package.json
Projects
None yet
Development

No branches or pull requests

1 participant