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

docs: add caution about scripts processing when using head config #1729

Merged
merged 2 commits into from
Apr 12, 2024

Conversation

jorenbroekema
Copy link
Contributor

Description

  • Closes Local Typescript files are not working #1704
  • What does this PR change? Adds some documentation about scripts processing when using the head config option, and what to do if you need scripts to be processed by Astro
  • Did you change something visual? No

Copy link

changeset-bot bot commented Apr 9, 2024

⚠️ No Changeset found

Latest commit: 55a6a26

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 9, 2024

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

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Apr 12, 2024 10:25am

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @jorenbroekema! Super helpful to have suggestions like this and know which parts of our docs tripped people up. Left one suggestion.

Comment on lines 447 to 450
:::caution
Scripts are placed into head using the `set:html` directive which is similar to using `is:inline` in that it [precludes these scripts from being processed by Astro](https://docs.astro.build/en/guides/client-side-scripts/#opting-out-of-processing).
This means that if you want to include a local script and you need this to be processed, you'll probably need to [override or extend the Head component](/guides/overriding-components/#reuse-a-built-in-component).
:::
Copy link
Member

Choose a reason for hiding this comment

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

Instead of a caution, I think we can add a clear description of how this does work (rather than specifying how it doesn’t):

Suggested change
:::caution
Scripts are placed into head using the `set:html` directive which is similar to using `is:inline` in that it [precludes these scripts from being processed by Astro](https://docs.astro.build/en/guides/client-side-scripts/#opting-out-of-processing).
This means that if you want to include a local script and you need this to be processed, you'll probably need to [override or extend the Head component](/guides/overriding-components/#reuse-a-built-in-component).
:::
Entries in `head` are converted directly to HTML elements and do not pass through Astro’s script or style processing.
If you need to import local assets like scripts, styles, or images, [override the Head component](/guides/overriding-components/#reuse-a-built-in-component).

This also helps us make this a bit simpler because we don’t need to explain too much all these other things which head isn’t, instead focusing on the simpler case of what it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I did embed a link to the Astro style and script docs in case users reading this will want to learn what this style and script processing is all about

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Perfect — thank you!

@delucis delucis merged commit 124d547 into withastro:main Apr 12, 2024
9 checks passed
thomasbnt added a commit to thomasbnt/starlight that referenced this pull request Apr 14, 2024
HiDeoo added a commit that referenced this pull request Apr 15, 2024
Co-authored-by: HiDeoo <494699+HiDeoo@users.noreply.github.com>
Co-authored-by: pioupia <49518790+pioupia@users.noreply.github.com>
HiDeoo added a commit to HiDeoo/starlight that referenced this pull request Apr 22, 2024
* main: (32 commits)
  i18n(pt-br): Update `getting-started.mdx` (withastro#1776)
  i18n(es): update `configuration` (withastro#1766)
  [ci] format
  Add TrueCharts to showcases (withastro#1773)
  i18n(zh-cn): Update `sidebar.mdx` (withastro#1761)
  i18n(ko-KR): update `sidebar.mdx` (withastro#1760)
  i18n(fr): update `guides/sidebar` (withastro#1758)
  test: fix Windows path separator test issues (withastro#1759)
  i18n(fr): Update `reference/configuration.mdx` from withastro#1729 (withastro#1757)
  docs: rewrite `guides/sidebar` examples to be more generic (withastro#1751)
  i18n(ja): Update community-content.mdx (withastro#1756)
  i18n(ja): Update configuration.mdx (withastro#1755)
  i18n(zh-cn): Update `configuration.mdx` (withastro#1753)
  i18n(ko-KR): update `configuration.mdx` (withastro#1752)
  docs: add caution about scripts processing when using head config (withastro#1729)
  i18n(es): update `community-content` (withastro#1740)
  i18n(pt-br): Update `resources/community-content.mdx` (withastro#1747)
  format: quick fix
  [ci] format
  [ci] format
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs Documentation website changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local Typescript files are not working
2 participants