-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds a
showCaptions
option to disable the current behavior of…
… displaying an image's alternate text as a caption when the image is zoomed
- Loading branch information
Showing
14 changed files
with
149 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
import starlightImageZoom from 'starlight-image-zoom' | ||
|
||
export default defineConfig({ | ||
base: '/no-caption/', | ||
integrations: [ | ||
starlight({ | ||
plugins: [starlightImageZoom({ showCaptions: false })], | ||
title: 'Starlight Image Zoom No Caption Example', | ||
}), | ||
], | ||
server: { | ||
port: 4322, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: Configuration | ||
description: An overview of all the configuration options supported by the Starlight Image Zoom plugin. | ||
--- | ||
|
||
The Starlight Image Zoom plugin can be configured inside the `astro.config.mjs` configuration file of your project: | ||
|
||
```js {11} | ||
// astro.config.mjs | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
import starlightImageZoom from 'starlight-image-zoom' | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
starlight({ | ||
plugins: [ | ||
starlightImageZoom({ | ||
// Configuration options go here. | ||
}), | ||
], | ||
title: 'My Docs', | ||
}), | ||
], | ||
}) | ||
``` | ||
|
||
## Configuration options | ||
|
||
The Starlight Image Zoom plugin accepts the following configuration options: | ||
|
||
### `showCaptions` | ||
|
||
**Type:** `boolean` | ||
**Default:** `true` | ||
|
||
Whether an image alternate text should be displayed as a caption when the image is zoomed. | ||
Disabling this options is useful if you are already using another approach to display captions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { ViteUserConfig } from 'astro' | ||
|
||
import type { StarlightImageZoomConfig } from '..' | ||
|
||
export function vitePluginStarlightImageZoomConfig(config: StarlightImageZoomConfig): VitePlugin { | ||
const moduleId = 'virtual:starlight-image-zoom-config' | ||
const resolvedModuleId = `\0${moduleId}` | ||
const moduleContent = `export default ${JSON.stringify(config)}` | ||
|
||
return { | ||
name: 'vite-plugin-starlight-image-zoom-config', | ||
load(id) { | ||
return id === resolvedModuleId ? moduleContent : undefined | ||
}, | ||
resolveId(id) { | ||
return id === moduleId ? resolvedModuleId : undefined | ||
}, | ||
} | ||
} | ||
|
||
type VitePlugin = NonNullable<ViteUserConfig['plugins']>[number] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from './test' | ||
|
||
test('does not add a caption if the `showCaptions` option is disabled', async ({ testPage }) => { | ||
await testPage.goto('zoom', true) | ||
|
||
await expect(testPage.getNthImage(0)).toBeZoomedAfterClick() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module 'virtual:starlight-image-zoom-config' { | ||
const StarlightImageZoomConfig: import('./index').StarlightImageZoomConfig | ||
|
||
export default StarlightImageZoomConfig | ||
} |