Skip to content

docs: code block example language - #11235

Merged
alaister merged 4 commits into
supabase:masterfrom
Hallidayo:docs-code-example-type
Jan 2, 2023
Merged

alaister merged 4 commits into
supabase:masterfrom
Hallidayo:docs-code-example-type

Conversation

@Hallidayo

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

Supabase Docs - Javascript & Dart references

What is the current behavior?

Currently on the docs the code block examples are using js so some dart keywords do not get highlighted:

Screenshot 2022-12-23 at 16 47 46

What is the new behavior?

Keywords are now highlighted:

Screenshot 2022-12-23 at 16 51 12

Also dart at the top of the dart examples has been removed.

Additional context

I've done this for js , ts and dart as these were the only examples I could see in the spec.

Closes #11225
Closes #11226

@Hallidayo
Hallidayo requested a review from a team as a code owner December 23, 2022 16:53
@vercel

vercel Bot commented Dec 23, 2022

Copy link
Copy Markdown

@Hallidayo is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Dec 23, 2022 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
docs ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 2, 2023 at 0:37AM (UTC)
supabase-studio-prod ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 2, 2023 at 0:37AM (UTC)
supabase-studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 2, 2023 at 0:37AM (UTC)
zone-www-dot-com ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 2, 2023 at 0:37AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
about ⬜️ Ignored (Inspect) Jan 2, 2023 at 0:37AM (UTC)

@dannykng dannykng left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice one @Hallidayo! Looping in @MildTomato and @saltcod for review.

@alaister alaister left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great @Hallidayo! Thank you 🙏🏻

Comment on lines +134 to +140
const codeBlockLang = example?.code?.includes('```js')
? 'js'
: example?.code?.includes('```ts')
? 'ts'
: example?.code?.includes('```dart')
? 'dart'
: 'js'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we able to use .startsWith() here instead of .includes()? Shouldn't be an issue really but might make it slightly safer 😅

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@alaister just changed this now to use .startsWith()

@alaister
alaister merged commit 3feb77f into supabase:master Jan 2, 2023
antlio pushed a commit that referenced this pull request Nov 20, 2026
## Problem

Three code blocks in the docs guides use the wrong language tag, so they
are highlighted and type-checked as JavaScript or TypeScript instead of
what they are:

- `guides/database/arrays.mdx`: a SQL query is tagged `js`
- `guides/database/import-data.mdx`: the `pgloader config.load` command
is tagged `jsx`
- `guides/ai/hybrid-search.mdx`: a cURL command is tagged `tsx`

The docs style guide says JavaScript and TypeScript blocks get type
hints and are formatted by Prettier, which does not apply to these
blocks.

## Solution

Retag the blocks: `sql` for the query and `bash` for the two shell
commands (`bash` is the most common shell tag in the guides).

For the SQL block I also lowercased the keywords, per the style guide's
"Prefer lowercase for SQL". Prettier's SQL plugin rewrites
`textarray[1]` to `textarray as [1]`, which is not valid Postgres, so
the block is preceded by `{/* prettier-ignore */}`, the same convention
already used in `guides/ai/engineering-for-scale.mdx` and
`guides/api/query-plans.mdx`.

Earlier PRs fixed the same kind of problem: #11870, #19033, #14856,
#11235.

## Review instructions

1. Open the diff: only the language tags change, plus the lowercase SQL
and the `prettier-ignore` comment in `arrays.mdx`.
2. Check the three pages in the preview: the SQL block in the SQL tab of
"Working with arrays", the `pgloader` step in "Import data into
Supabase", and the cURL block in "Hybrid search".
3. Run `pnpm test:prettier`. It passes for these files with the repo's
`prettier.config.mjs`.

## Checklist

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide).
(Not run: this edit only changes code fence languages, and I applied the
style guide's code block rules by hand.)

Co-authored-by: Santhosh-x23 <[email protected]>

This branch was successfully deployed

4 active deployments
Preview – zone-www-dot-com — 35233c27 Deployed Jan 2, 2023 by vercel[bot]
Preview – supabase-studio-prod — 35233c27 Deployed Jan 2, 2023 by vercel[bot]
Preview – supabase-studio-staging — 35233c27 Deployed Jan 2, 2023 by vercel[bot]
Preview – docs — 35233c27 Deployed Jan 2, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Better syntax highlighting for Dart code examples docs: Every Dart code example is prefixed with dart

3 participants