Skip to content

Commit

Permalink
fix: boolean data attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo committed Nov 17, 2024
1 parent 6583163 commit 214d8b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions packages/starlight/components/Page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ const pagefindEnabled =
Astro.props.entry.slug !== '404' &&
!Astro.props.entry.slug.endsWith('/404') &&
Astro.props.entry.data.pagefind !== false;
const dataAttributes: DOMStringMap = { 'data-theme': 'dark' };
if (Boolean(Astro.props.toc)) dataAttributes['data-has-toc'] = '';
if (Astro.props.hasSidebar) dataAttributes['data-has-sidebar'] = '';
if (Boolean(Astro.props.entry.data.hero)) dataAttributes['data-has-hero'] = '';
---

<html
lang={Astro.props.lang}
dir={Astro.props.dir}
data-has-toc={Boolean(Astro.props.toc)}
data-has-sidebar={Astro.props.hasSidebar}
data-has-hero={Boolean(Astro.props.entry.data.hero)}
data-theme="dark"
>
<html lang={Astro.props.lang} dir={Astro.props.dir} {...dataAttributes}>
<head>
<Head {...Astro.props} />
<style>
Expand Down
8 changes: 4 additions & 4 deletions packages/starlight/components/Search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const pagefindTranslations = {
.map(([key, value]) => [key.replace('pagefind.', ''), value])
),
};
const dataAttributes: DOMStringMap = { 'data-translations': JSON.stringify(pagefindTranslations) };
if (project.trailingSlash === 'never') dataAttributes['data-strip-trailing-slash'] = '';
---

<site-search
data-translations={JSON.stringify(pagefindTranslations)}
data-strip-trailing-slash={project.trailingSlash === 'never'}
>
<site-search class={Astro.props.class} {...dataAttributes}>
<button
data-open-modal
disabled
Expand Down

0 comments on commit 214d8b4

Please sign in to comment.