Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

fix fallback block for *.md files - #230

Merged
jaked merged 2 commits into
mainfrom
jaked/match-specificity
Dec 6, 2022
Merged

fix fallback block for *.md files#230
jaked merged 2 commits into
mainfrom
jaked/match-specificity

Conversation

@jaked

@jaked jaked commented Dec 6, 2022

Copy link
Copy Markdown
Contributor

Right now *.md files without a specific default block set in metadata fall back to the use case block rather than the Markdown block. The rules for choosing the fallback block are currently:

  • the first blocks-example block that matches the path but doesn't include * in matches
  • or else the first blocks-example block that matches the path

The Markdown block matches ["*.md", "*.markdown", "*"] and the use case block matches ["*.md", "*.markdown"], so the use case block is preferred by the first rule.

@Wattenberger and I discussed and decided to

  1. remove the use case block from blocks-examples
  2. change the fallback rules to
    • the first blocks-example block that matches the path but doesn't include * in matches
    • or else the first blocks-example block that matches the path but doesn't use * to match it
    • or else the first blocks-example block that matches the path

(Without the new rule, *.md files would fall back to the code block since it's sorted ahead of the Markdown block.)

This change is part 2 of that, and I also filtered out the use case block pending part 1.

Comment thread hooks/index.tsx
Comment on lines 3 to 14
import { AppContext } from "context";
import {
BlocksQueryMeta,
checkAccess,
createBranchAndPR,
CreateBranchParams,
CreateBranchResponse,
getBlocksFromRepo,
getBlocksRepos,
getBranches,
getFileContent,
getFolderContent,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I organized imports, sorry for noise

Comment thread hooks/index.tsx Outdated
)?.blocks ?? [];
blocksRepos
.find((b) => b.owner === "githubnext" && b.repo === "blocks-examples")
// TODO(jaked) remove when use-case-block is removed from blocks-examples

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be good here, now that githubnext/blocks-examples#70 is merged & pushed!

@Wattenberger Wattenberger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@jaked
jaked merged commit 17056cc into main Dec 6, 2022
@jaked
jaked deleted the jaked/match-specificity branch December 6, 2022 18:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants