Skip to content

Fix TypeScript errors in "Add content to your site" code snippets#14091

Merged
ArmandPhilippot merged 11 commits into
mainfrom
armand/fix-add-content-code-snippets
Jun 19, 2026
Merged

Fix TypeScript errors in "Add content to your site" code snippets#14091
ArmandPhilippot merged 11 commits into
mainfrom
armand/fix-add-content-code-snippets

Conversation

@ArmandPhilippot

@ArmandPhilippot ArmandPhilippot commented Jun 18, 2026

Copy link
Copy Markdown
Member

Description (required)

Follow-up of #14089. TL;DR: prevent red squiggles in our code snippets to improve UX.

Fixes code snippets in "Add content to your site":

  • images.mdx:
    • TypeScript complains without an explicit alt on <Image />
    • getElementById can return null
  • content-collections.mdx:
    • missing imports
    • consistent quotes (single/double in the same code snippet), see Fix TypeScript errors in "Configuration" & "Routing and navigation" code snippets #14089 for the reasoning about formatting
    • getEntry()/getLiveEntry() may return undefined
    • a schema above defined pubDate not published
    • not fix for undefined properties (ie. data.*) since they depends on a schema not shown here
    • Astro.params.slug is incompatible with getLiveEntry() without an if statement
    • Astro.params.id can be undefined
    • TypeScript complains about post.frontmatter.title without post: any (no type for import.meta.glob)

To help review and explain my changes I made a commit per code snippet (with a few exceptions where the changes were the same), with a short explanation of why in the commit message.

Related issues & labels (optional)

  • Suggested label: code snippet update

@ArmandPhilippot ArmandPhilippot added the code snippet update Updates a code sample: typo, outdated code etc. label Jun 18, 2026
@ArmandPhilippot ArmandPhilippot changed the title Armand/fix add content code snippets Fix TypeScript errors in "Add content to your site" code snippets Jun 18, 2026
@astrobot-houston

astrobot-houston commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/content-collections.mdx Source changed, localizations will be marked as outdated.
en/guides/images.mdx Source changed, localizations will be marked as outdated.
en/guides/markdown-content.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Preview deployment

✅ Deployment complete!

@yanthomasdev yanthomasdev 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.

LGTM!

@ArmandPhilippot ArmandPhilippot merged commit c93b44b into main Jun 19, 2026
9 checks passed
@ArmandPhilippot ArmandPhilippot deleted the armand/fix-add-content-code-snippets branch June 19, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code snippet update Updates a code sample: typo, outdated code etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants