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 script reads the files in the dist directory and creates a new exports object in the package.json file | |
with the appropriate svelte and types paths for each Svelte component file found in the dist directory, | |
except for index.js and index.d.ts. | |
The resulting exports object is structured as follows: | |
"exports": { | |
".": { | |
"types": "./dist/index.d.ts", | |
"svelte": "./dist/index.js" | |
}, |
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
// Use this script where you have sub-directories | |
// This script reads the files in the dist directory and creates a new exports object in the package.json file | |
import fs from 'fs'; | |
import path from 'path'; | |
const distDir = './dist'; | |
const packageJsonPath = './package.json'; | |
const componentNames = fs.readdirSync(distDir); | |
const componentExports = {}; |
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
<script> | |
import { Heading, Button, Modal, ImagePlaceholder, TextPlaceholder } from 'flowbite-svelte' | |
let defaultModal = false; | |
</script> | |
<Heading tag="h1" customSize="text-5xl">My website</Heading> | |
<ImagePlaceholder class='my-4'/> | |
<Button on:click={() => defaultModal = true} class='mb-4'>Default modal</Button> | |
<TextPlaceholder class='pb-8' size='xxl'/> | |
<TextPlaceholder class='pb-8' size='xxl'/> |
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
<script lang='ts'> | |
import "../app.postcss" | |
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger, Footer, FooterBrand, FooterCopyright, FooterLinkGroup, FooterLink, Hr } from 'flowbite-svelte' | |
</script> | |
<Navbar let:hidden let:toggle> | |
<NavBrand href="/"> | |
<img | |
src="https://flowbite-svelte.com/images/flowbite-svelte-icon-logo.svg" | |
class="mr-3 h-6 sm:h-9" |
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
<script lang='ts'> | |
import "../app.postcss" | |
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger } from 'flowbite-svelte' | |
</script> | |
<Navbar let:hidden let:toggle> | |
<NavBrand href="/"> | |
<img | |
src="https://flowbite-svelte.com/images/flowbite-svelte-icon-logo.svg" | |
class="mr-3 h-6 sm:h-9" |
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
/* | |
Use this with the following script | |
``` | |
"write-package-json": "node ./scripts/package-json-writer.js", | |
"add-exports": "node ./scripts/add-exports-to-package-json.js", | |
"package:publish": "standard-version && git push --follow-tags origin main && npm run package && | |
npm run add-exports && npm run write-package-json && npm publish", | |
``` | |
This script reads the content of a folder named 'dist' and generates an exports object to be included in the |
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
// reference https://dev.to/builderio/safe-data-fetching-in-modern-javascript-dp4 | |
class ResponseError extends Error { | |
constructor(message, res) { | |
super(message) | |
this.response = res | |
} | |
} | |
export async function myFetch(...options) { |
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
<%- include('partials/header',{title:title}); %> | |
<h1 class="text-4xl font-bold dark:text-white py-8"> | |
<%= title %> | |
</h1> | |
<h2 class="text-3xl dark:text-white py-4">Examples</h2> | |
<div class="flex flex-wrap justify-between"> | |
<div class="my-4 max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow-md dark:bg-gray-800 dark:border-gray-700"> | |
<a href="/location"> |
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
// src/worldcities.js | |
import { client } from './redis.js'; | |
export const addIntCities = () => { | |
client.geoadd('cities', 0.0000, 0.0000, "North Pole"); | |
client.geoadd('cities', -0.1278, 51.5074, "London"); | |
client.geoadd('cities', -3.7032, 40.4168, "Madrid"); | |
client.geoadd('cities', -77.0369, 38.9072, "Washington D.C."); | |
client.geoadd('cities', 139.6917, 35.6895, "Tokyo") |
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
// src/uscities.js | |
import { client } from './redis.js'; | |
export const addUsCities = () => { | |
client.geoadd('uscities', -71.0589, 42.3601, "Boston, Massachusetts"); | |
client.geoadd('uscities', -75.1652, 39.9526, "Philadelphia, Pennsylvania"); | |
client.geoadd('uscities', -112.0740, 33.4484, "Phoenix, Arizona"); | |
client.geoadd('uscities', -98.4936, 29.4241, "San Antonio, Texas"); | |
client.geoadd('uscities', -121.8949, 37.3382, "San Jose, California"); | |
client.geoadd('uscities', -97.7431, 30.2672, "Austin, Texas"); |