-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4da03d6
commit ab7b842
Showing
17 changed files
with
2,303 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"starlight-plugin-show-latest-version-docs": minor | ||
--- | ||
|
||
Documentation of first minor version of plugin |
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 @@ | ||
--- | ||
"starlight-plugin-show-latest-version": minor | ||
--- | ||
|
||
Release first minor version. Latest version in site title and virtual module export. |
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,56 @@ | ||
--- | ||
title: Exports | ||
description: An overview of all values and components exported by the Starlight Plugin Show Latest Version plugin. | ||
--- | ||
|
||
import { Aside, Badge } from "@astrojs/starlight/components"; | ||
import context from "virtual:starlight-plugin-show-latest-version-context"; | ||
|
||
The Starlight Plugin Show Latest Version plugin exports a virtual module which allows you to use the plugin's calculated values in your own code. | ||
|
||
## Import | ||
|
||
```ts | ||
import version from "virtual:starlight-plugin-show-latest-version-context"; | ||
``` | ||
|
||
## Usage | ||
|
||
```mdx | ||
{context.versionAvailable && <Badge text={context.version} size="medium" />} | ||
``` | ||
|
||
{context.versionAvailable && ( | ||
|
||
<Aside type="tip" title="Preview"> | ||
<Badge text={context.version} size="medium" /> | ||
</Aside> | ||
|
||
)} | ||
|
||
## Available values | ||
|
||
Since the type of the exported virtual modules looks like this: | ||
|
||
```ts | ||
export const VersionState = z.union([ | ||
z.object({ | ||
versionAvailable: z.literal(true), | ||
version: z.string(), | ||
versionWithoutPrefix: z.string(), | ||
versionMajor: z.number(), | ||
versionMinor: z.number(), | ||
versionPatch: z.number(), | ||
prerelease: z.string().optional(), | ||
isPrereleaseVersion: z.boolean(), | ||
prefix: z.string().optional(), | ||
hasVPrefix: z.boolean(), | ||
isStableVersion: z.boolean(), | ||
}), | ||
z.object({ | ||
versionAvailable: z.literal(false), | ||
}), | ||
]); | ||
``` | ||
|
||
you have access to properties such as `version`, `versionWithoutPrefix`, `versionMajor`, `versionMinor`, `versionPatch`, `prerelease`, `isPrereleaseVersion`, `prefix`, `hasVPrefix`, `isStableVersion` under the condition that the version was parseable (`versionAvailable` is `true`). |
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
2 changes: 2 additions & 0 deletions
2
packages/starlight-plugin-show-latest-version/consts/semantic.version.pattern.ts
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,2 @@ | ||
export const SEMVER_PATTERN = | ||
/^(?:v|[^0-9\s]*@)?v?(?<version>[0-9]+\.[0-9]+\.[0-9]+)(?:-(?<prerelease>[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*))?(?![-.]|[^-\w.])$/; |
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 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} **/ | ||
export default { | ||
testEnvironment: "node", | ||
transform: { | ||
"^.+.tsx?$": ["ts-jest",{}], | ||
}, | ||
}; |
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
28 changes: 20 additions & 8 deletions
28
packages/starlight-plugin-show-latest-version/libs/types.ts
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 |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import { z } from "astro/zod"; | ||
|
||
const contextSchema = z.object({ | ||
version: z.string(), | ||
versionWithoutPrefix: z.string(), | ||
versionPatch: z.number(), | ||
versionMinor: z.number(), | ||
versionMajor: z.number(), | ||
}); | ||
// Enum-like structure for the version state | ||
export const VersionState = z.union([ | ||
z.object({ | ||
versionAvailable: z.literal(true), | ||
version: z.string(), | ||
versionWithoutPrefix: z.string(), | ||
versionMajor: z.number(), | ||
versionMinor: z.number(), | ||
versionPatch: z.number(), | ||
prerelease: z.string().optional(), | ||
isPrereleaseVersion: z.boolean(), | ||
prefix: z.string().optional(), | ||
hasVPrefix: z.boolean(), | ||
isStableVersion: z.boolean(), | ||
}), | ||
z.object({ | ||
versionAvailable: z.literal(false), | ||
}), | ||
]); | ||
|
||
export type StarlightPluginShowLatestVersionContext = z.infer< | ||
typeof contextSchema | ||
typeof VersionState | ||
>; |
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
Oops, something went wrong.