diff --git a/scripts/updateStars.js b/scripts/updateStars.js index 9298c01..f7991ae 100644 --- a/scripts/updateStars.js +++ b/scripts/updateStars.js @@ -12,7 +12,7 @@ import prettier from 'prettier'; const files = [ 'src/routes/components/components.json', 'src/routes/templates/templates.json', - 'src/routes/tooling/tools.json' + 'src/routes/tools/tools.json' ]; if (!process.env.GH_TOKEN) { diff --git a/src/lib/components/layout/Header.svelte b/src/lib/components/layout/Header.svelte index d34a823..5f0622c 100644 --- a/src/lib/components/layout/Header.svelte +++ b/src/lib/components/layout/Header.svelte @@ -5,7 +5,7 @@ const linksLeft = [ ['/templates', 'templates'], ['/components', 'components'], - ['/tooling', 'tooling'] + ['/tools', 'tools'] ]; const linksRight = [ ['/recipes', 'recipes'], diff --git a/src/routes/components/index.svelte b/src/routes/components/index.svelte index 823cdd4..63323de 100644 --- a/src/routes/components/index.svelte +++ b/src/routes/components/index.svelte @@ -87,7 +87,7 @@ - Submit a component + Submit a component + import SvelteSelect from 'svelte-select'; + import components from '../components/components.json'; + import templates from '../templates/templates.json'; + import tools from '../tools/tools.json'; + import { tick } from 'svelte'; + import { page } from '$app/stores'; + import { copyToClipboard } from '$lib/utils/clipboard'; + import { extractUnique } from '$lib/utils/extractUnique'; + + const repoURL = 'https://github.com/svelte-society/sveltesociety.dev'; + const typeQuery = $page.query.get('type'); + const types = ['Component', 'Template', 'Tool'].map((t) => ({ + label: t, + value: t.toLowerCase() + })); + + const data = { + component: { + tags: extractUnique(components, 'tags'), + categories: [...extractUnique(components, 'category').filter((cat) => cat.label !== '')] + }, + template: { + tags: extractUnique(templates, 'tags'), + categories: extractUnique(templates, 'category') + }, + tool: { + tags: extractUnique(tools, 'tags'), + categories: extractUnique(tools, 'category') + } + }; + + let clipboardCopy = false; + const copy = () => { + copyToClipboard(JSON.stringify(jsonSnippet, null, 4)).then(() => (clipboardCopy = false)); + clipboardCopy = true; + }; + + let type = types.find((t) => t.value == typeQuery) || types[0]; + let title = 'svelte-lorem-ipsum'; + let url = 'https://github.com/sveltejs/svelte-lorem-ipsum'; + let description = 'A dummy text generator that does not exist'; + let npm = 'svelte-lorem-ipsum'; + let addedOn = todaysDate(); + let category; + let tags; + + $: pathName = `${type.value}s`; + $: jsonSnippet = { + title, + url, + description, + npm, + addedOn, + category: category?.value, + tags: tags?.map((tag) => tag.value) + }; + + $: currentTags = data[type.value].tags; + $: currentCategories = data[type.value].categories; + + function padWithZero(date) { + return date.toString().padStart(2, '0'); + } + + function todaysDate() { + const date = new Date(); + const day = padWithZero(date.getDate()); + const month = padWithZero(date.getMonth() + 1); + const year = date.getFullYear(); + const sep = '-'; + return [year, month, day].join(sep); + } + + async function clearCategoryAndTags() { + await tick(); + category = null; + tags = null; + } + + +
+ To add a new component on the website, the process is rather simple. You have to add a snippet in + the appropriate file. +
+ ++ Each component is represented by a JSON Object. Use the generator below to generate the Object. +
+ +* marked fields are required
+ {JSON.stringify(jsonSnippet,null,4)}
+
+