diff --git a/.gitignore b/.gitignore
index 6c69f85..ff34cfc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,6 @@ package
dist
node_modules
.svelte-kit
+.svelte-kit/build
public/build
webpack/public
-.astro
\ No newline at end of file
diff --git a/README.md b/README.md
index b83b585..1a5f30b 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,8 @@ yarn add svelte-time
The displayed time defaults to `new Date().toISOString()` and is formatted as `"MMM DD, YYYY"`.
+
+
```svelte
`;
+ const html = await marked.parse(code);
+
+ return importsBlock + html;
+ }
+ },
+ };
+};
diff --git a/public/favicon.svg b/public/favicon.svg
new file mode 100644
index 0000000..ec91bb9
--- /dev/null
+++ b/public/favicon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/www/components/Basic.svelte b/tests/examples/Basic.svelte
similarity index 100%
rename from www/components/Basic.svelte
rename to tests/examples/Basic.svelte
diff --git a/www/components/CodeDemo.svelte b/tests/examples/CodeDemo.svelte
similarity index 100%
rename from www/components/CodeDemo.svelte
rename to tests/examples/CodeDemo.svelte
diff --git a/www/components/CustomFormat.svelte b/tests/examples/CustomFormat.svelte
similarity index 100%
rename from www/components/CustomFormat.svelte
rename to tests/examples/CustomFormat.svelte
diff --git a/www/components/CustomLocale.svelte b/tests/examples/CustomLocale.svelte
similarity index 100%
rename from www/components/CustomLocale.svelte
rename to tests/examples/CustomLocale.svelte
diff --git a/www/components/CustomTimestamp.svelte b/tests/examples/CustomTimestamp.svelte
similarity index 100%
rename from www/components/CustomTimestamp.svelte
rename to tests/examples/CustomTimestamp.svelte
diff --git a/www/components/CustomTimezone.svelte b/tests/examples/CustomTimezone.svelte
similarity index 100%
rename from www/components/CustomTimezone.svelte
rename to tests/examples/CustomTimezone.svelte
diff --git a/www/components/DayjsExport.svelte b/tests/examples/DayjsExport.svelte
similarity index 100%
rename from www/components/DayjsExport.svelte
rename to tests/examples/DayjsExport.svelte
diff --git a/www/components/RelativeTime.svelte b/tests/examples/RelativeTime.svelte
similarity index 100%
rename from www/components/RelativeTime.svelte
rename to tests/examples/RelativeTime.svelte
diff --git a/www/components/RelativeTimeCustomFormat.svelte b/tests/examples/RelativeTimeCustomFormat.svelte
similarity index 100%
rename from www/components/RelativeTimeCustomFormat.svelte
rename to tests/examples/RelativeTimeCustomFormat.svelte
diff --git a/www/components/RelativeTimeCustomTitle.svelte b/tests/examples/RelativeTimeCustomTitle.svelte
similarity index 100%
rename from www/components/RelativeTimeCustomTitle.svelte
rename to tests/examples/RelativeTimeCustomTitle.svelte
diff --git a/www/components/RelativeTimeNoTitle.svelte b/tests/examples/RelativeTimeNoTitle.svelte
similarity index 100%
rename from www/components/RelativeTimeNoTitle.svelte
rename to tests/examples/RelativeTimeNoTitle.svelte
diff --git a/www/components/SvelteTimeAction.svelte b/tests/examples/SvelteTimeAction.svelte
similarity index 100%
rename from www/components/SvelteTimeAction.svelte
rename to tests/examples/SvelteTimeAction.svelte
diff --git a/tests/index.html b/tests/index.html
new file mode 100644
index 0000000..903ded4
--- /dev/null
+++ b/tests/index.html
@@ -0,0 +1,7 @@
+
diff --git a/tsconfig.json b/tsconfig.json
index 8160084..dfa1fd5 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -3,11 +3,15 @@
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noImplicitAny": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
+ "resolveJsonModule": true,
"strict": true,
"types": ["svelte", "vitest/globals"],
"paths": {
@@ -15,5 +19,5 @@
"svelte-time/*": ["./src/*"]
}
},
- "include": ["src", "tests", "www"]
+ "include": ["src", "tests", "plugin-readme.ts", "vite.config.ts"]
}
diff --git a/vite.config.ts b/vite.config.ts
index 3ee4d93..a553dff 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,26 +1,28 @@
-import { svelte, vitePreprocess } from "@sveltejs/vite-plugin-svelte";
+import { svelte } from "@sveltejs/vite-plugin-svelte";
import path from "node:path";
import { defineConfig } from "vite";
import pkg from "./package.json";
+import { pluginReadme } from "./plugin-readme";
-export default defineConfig(({ mode }) => ({
+export default defineConfig({
+ base: "/" + pkg.name,
+ root: "./tests",
+ build: { outDir: "../dist", emptyOutDir: true },
plugins: [
+ pluginReadme({
+ title: pkg.name,
+ description: pkg.description,
+ watchDir: "./tests/examples",
+ baseUrl: "https://github.com/metonym/svelte-time/tree/master/",
+ }),
svelte({
- compilerOptions: {
- runes: true,
- },
- hot: false,
- preprocess: [vitePreprocess()],
+ compilerOptions: { runes: true },
+ extensions: [".svelte", ".md"],
}),
],
resolve: {
- alias: {
- [pkg.name]: path.resolve("./src"),
- },
- conditions: mode === "test" ? ["browser"] : [],
- },
- test: {
- globals: true,
- environment: "jsdom",
+ alias: { [pkg.name]: path.resolve("./src") },
+ conditions: ["browser"],
},
-}));
+ test: { globals: true, environment: "jsdom" },
+});
diff --git a/www/layouts/Layout.astro b/www/layouts/Layout.astro
deleted file mode 100644
index c8b3696..0000000
--- a/www/layouts/Layout.astro
+++ /dev/null
@@ -1,37 +0,0 @@
----
-import "github-markdown-css/github-markdown-dark.css";
----
-
-
-
-
-
-
-
- svelte-time
-
-
-
-
-
-
-
-
-
diff --git a/www/pages/index.mdx b/www/pages/index.mdx
deleted file mode 100644
index 9fe66fc..0000000
--- a/www/pages/index.mdx
+++ /dev/null
@@ -1,427 +0,0 @@
----
-layout: ../layouts/Layout.astro
----
-
-import CodeDemo from "../components/CodeDemo.svelte";
-import Basic from "../components/Basic.svelte";
-import CustomTimestamp from "../components/CustomTimestamp.svelte";
-import CustomFormat from "../components/CustomFormat.svelte";
-import RelativeTime from "../components/RelativeTime.svelte";
-import RelativeTimeCustomFormat from "../components/RelativeTimeCustomFormat.svelte";
-import RelativeTimeCustomTitle from "../components/RelativeTimeCustomTitle.svelte";
-import RelativeTimeNoTitle from "../components/RelativeTimeNoTitle.svelte";
-import SvelteTimeAction from "../components/SvelteTimeAction.svelte";
-import DayjsExport from "../components/DayjsExport.svelte";
-import CustomLocale from "../components/CustomLocale.svelte";
-import CustomTimezone from "../components/CustomTimezone.svelte";
-
-# svelte-time
-
-[![NPM][npm]][npm-url]
-
-**Note:** `svelte-time@2.0.0` only supports Svelte 5 in Runes mode.
-
-Use [svelte-time@1.0.0](https://github.com/metonym/svelte-time/tree/v1.0.0) for Svelte 3, 4, and 5 (non-Runes mode).
-
----
-
-`svelte-time` is a Svelte component and action to make a timestamp human-readable while encoding the machine-parseable value in the semantic `time` element.
-
-Under the hood, it uses [day.js](https://github.com/iamkun/dayjs), a lightweight date-time library.
-
-```svelte
-
-
-
-
-
-```
-
-Try it in the [Svelte REPL](https://svelte.dev/playground/e2a27786f93d42878388de482de403c9).
-
----
-
-## Installation
-
-```bash
-# npm
-npm i svelte-time
-
-# pnpm
-pnpm i svelte-time
-
-# Bun
-bun i svelte-time
-
-# Yarn
-yarn add svelte-time
-```
-
-Note that [pnpm](https://github.com/pnpm/pnpm) users must also install `dayjs`.
-
-## Usage
-
-### `Time` component
-
-The displayed time defaults to `new Date().toISOString()` and is formatted as `"MMM DD, YYYY"`.
-
-
-
-
-
-```svelte
-
-
-
-```
-
-The `timestamp` prop can be any of the following `dayjs` values: `string | number | Date | Dayjs`.
-
-
-
-
-
-```svelte
-
-
-
-
-
-```
-
-Use the `format` prop to format the timestamp. Refer to the [dayjs format documentation](https://day.js.org/docs/en/display/format) for acceptable formats.
-
-
-
-
-
-```svelte
-
-
-
-
-
-```
-
-### Relative time
-
-Set the `relative` prop value to `true` for the relative time displayed in a human-readable format.
-
-
-
-
-
-```svelte
-
-
-
-
-
-```
-
-When using relative time, the `title` attribute will display a formatted timestamp.
-
-Use the `format` prop to customize the [format](https://day.js.org/docs/en/display/format).
-
-
-
-
-
-```svelte
-
-```
-
-When using `relative`, the `time` element will set the formatted timestamp as the `title` attribute. Specify a custom `title` to override this.
-
-
-
-
-
-```svelte
-
-```
-
-Set the value to `undefined` to omit the `title` altogether.
-
-
-
-
-
-```svelte
-
-```
-
-### Live updates
-
-Set `live` to `true` for a live updating relative timestamp. The default refresh interval is 60 seconds.
-
-```svelte
-
-```
-
-To customize the interval, pass a value to `live` in milliseconds (ms).
-
-```svelte
-
-
-
-
-
-```
-
-### `svelteTime` action
-
-An alternative to the `Time` component is to use the `svelteTime` action to format a timestamp in a raw HTML element.
-
-The API is the same as the `Time` component.
-
-
-
-
-
-```svelte
-
-
-
-
-
-```
-
-#### Relative time
-
-Set `relative` to `true` to use relative time.
-
-```svelte
-
-
-
-```
-
-To customize or omit the `title` attribute, use the `title` prop.
-
-```svelte
-
-
-
-```
-
-Similar to the `Time` component, the `live` prop only works with relative time.
-
-```svelte
-
-```
-
-Specify a custom update interval using the `live` prop.
-
-```svelte
-
-```
-
-### `dayjs` export
-
-The `dayjs` library is exported from this package for your convenience.
-
-**Note**: the exported `dayjs` function already extends the [relativeTime plugin](https://day.js.org/docs/en/plugin/relative-time).
-
-
-
-
-
-```svelte
-
-
-
-```
-
-### Custom locale
-
-The default `dayjs` locale is English. No other locale is loaded by default for performance reasons.
-
-To use a [custome locale](https://day.js.org/docs/en/i18n/changing-locale), import the relevant language from `dayjs`. See a list of [supported locales](https://github.com/iamkun/dayjs/tree/dev/src/locale).
-
-
-
-
-
-```svelte
-
-
-
-```
-
-### Custom locale (global)
-
-Use the [`dayjs.locale`](https://day.js.org/docs/en/i18n/changing-locale) method to set a custom locale as the default.
-
-```svelte
-
-```
-
-### Custom timezone
-
-To use a [custom timezone](https://day.js.org/docs/en/timezone/timezone), import the `utc` and `timezone` plugins from `dayjs`.
-
-
-
-
-
-```svelte
-
-
-
-```
-
-### Custom timezone (global)
-
-Use the [`dayjs.tz.setDefault`](https://day.js.org/docs/en/timezone/default-timezone) method to set a custom timezone as the default.
-
-```svelte
-
-```
-
-### User timezone
-
-Use the [`dayjs.ts.guess`](https://day.js.org/docs/en/timezone/guessing-user-timezone) method to guess the user's timezone.
-
-```js
-import utc from "dayjs/plugin/utc";
-import timezone from "dayjs/plugin/timezone";
-
-dayjs.extend(utc);
-dayjs.extend(timezone);
-
-dayjs.tz.guess(); // America/New_York
-```
-
-To retrieve the abbreviated time zone, extend the [`advancedFormat`](https://day.js.org/docs/en/plugin/advanced-format) plugin.
-
-```diff
- import utc from "dayjs/plugin/utc";
- import timezone from "dayjs/plugin/timezone";
-+ import advancedFormat from "dayjs/plugin/advancedFormat";
-
- import { dayjs } from "svelte-time";
-
- dayjs.extend(utc);
- dayjs.extend(timezone);
-+ dayjs.extend(advancedFormat);
-```
-
-Then, use the [`dayjs().local`](https://day.js.org/docs/en/manipulate/local) method to get the user's local time zone and format it using the `"z"` advanced option.
-
-```js
-dayjs().local().format("z"); // EST
-dayjs().local().format("zzz"); // Eastern Standard Time
-```
-
-## API
-
-### Props
-
-| Name | Type | Default value |
-| :-------- | :---------------------------------------------------- | :--------------------------------------------------------------------------------------- |
-| timestamp | `string` | `number` | `Date` | `Dayjs` | `new Date().toISOString()` |
-| format | `string` | `"MMM DD, YYYY"` (See [dayjs display format](https://day.js.org/docs/en/display/format)) |
-| relative | `boolean` | `false` |
-| live | `boolean` | `number` | `false` |
-| formatted | `string` | `""` |
-
-## Examples
-
-- [examples/sveltekit](https://github.com/metonym/svelte-time/tree/master/examples/sveltekit)
-- [examples/vite](https://github.com/metonym/svelte-time/tree/master/examples/vite)
-- [examples/rollup](https://github.com/metonym/svelte-time/tree/master/examples/rollup)
-- [examples/webpack](https://github.com/metonym/svelte-time/tree/master/examples/webpack)
-
-## Changelog
-
-[CHANGELOG.md](https://github.com/metonym/svelte-time/blob/master/CHANGELOG.md)
-
-## License
-
-[MIT](https://github.com/metonym/svelte-time/blob/master/LICENSE)
-
-[npm]: https://img.shields.io/npm/v/svelte-time.svg?style=for-the-badge&color=%23ff3e00
-[npm-url]: https://npmjs.com/package/svelte-time
diff --git a/www/public/favicon.svg b/www/public/favicon.svg
deleted file mode 100644
index cf8388e..0000000
--- a/www/public/favicon.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-