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 - -