diff --git a/website-sveltekit/.gitignore b/website-sveltekit/.gitignore new file mode 100644 index 0000000..6635cf5 --- /dev/null +++ b/website-sveltekit/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +node_modules +/build +/.svelte-kit +/package +.env +.env.* +!.env.example +vite.config.js.timestamp-* +vite.config.ts.timestamp-* diff --git a/website-sveltekit/.npmrc b/website-sveltekit/.npmrc new file mode 100644 index 0000000..b6f27f1 --- /dev/null +++ b/website-sveltekit/.npmrc @@ -0,0 +1 @@ +engine-strict=true diff --git a/website-sveltekit/README.md b/website-sveltekit/README.md new file mode 100644 index 0000000..5c91169 --- /dev/null +++ b/website-sveltekit/README.md @@ -0,0 +1,38 @@ +# create-svelte + +Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). + +## Creating a project + +If you're seeing this, you've probably already done this step. Congrats! + +```bash +# create a new project in the current directory +npm create svelte@latest + +# create a new project in my-app +npm create svelte@latest my-app +``` + +## Developing + +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: + +```bash +npm run dev + +# or start the server and open the app in a new browser tab +npm run dev -- --open +``` + +## Building + +To create a production version of your app: + +```bash +npm run build +``` + +You can preview the production build with `npm run preview`. + +> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. diff --git a/website-sveltekit/demo-data/pages/about.md b/website-sveltekit/demo-data/pages/about.md new file mode 100644 index 0000000..485dd77 --- /dev/null +++ b/website-sveltekit/demo-data/pages/about.md @@ -0,0 +1,11 @@ + + +

Directus is an Open Data Platform purpose-built for democratizing the world's data. By staying small and agile, we remain completely focused on the product itself, avoiding the financial trap that often comes with taking on capital too early and concentrating solely on sales and rapid expansion. We believe in stable, informed growth, with every decision based on real-world usage and research.

+

A team of passionate creators

+

We are a team of developers, designers, innovators, and entrepreneurs, all laser-focused on building something truly amazing.

+

An all-remote team

+

Our team is 100% remote, with flexible working hours, asynchronous communication, and the freedom to work from anywhere that has a reliable internet connection.

+

International by design

+

To build a global platform, you need a global team. It's no accident that our talented, diverse, and multilingual team is distributed around the entire world.

+

Contributor-first hiring

+

Many of our hires start off as contributors, so they are already familiar with our codebase, understand the pull request flow, and are engaged in open-source.

\ No newline at end of file diff --git a/website-sveltekit/demo-data/pages/conduct.md b/website-sveltekit/demo-data/pages/conduct.md new file mode 100644 index 0000000..e9c55ef --- /dev/null +++ b/website-sveltekit/demo-data/pages/conduct.md @@ -0,0 +1,48 @@ + + +

Our Pledge

+

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

+

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

+

Our Standards

+

Examples of behavior that contributes to a positive environment for our community include:

+ +

Examples of unacceptable behavior include:

+ +

Enforcement Responsibilities

+

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

+

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

+

Scope

+

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

+

Enforcement

+

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.

+

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

+

Enforcement Guidelines

+

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

+

1. Correction

+

Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

+

Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

+

2. Warning

+

Community Impact: A violation through a single incident or series of actions.

+

Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

+

3. Temporary Ban

+

Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

+

Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

+

4. Permanent Ban

+

Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

+

Consequence: A permanent ban from any sort of public interaction within the community.

+

Attribution

+

This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.

+

Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder.

+

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

\ No newline at end of file diff --git a/website-sveltekit/demo-data/pages/privacy.md b/website-sveltekit/demo-data/pages/privacy.md new file mode 100644 index 0000000..ec45499 --- /dev/null +++ b/website-sveltekit/demo-data/pages/privacy.md @@ -0,0 +1,21 @@ + + + +

Information that is gathered from visitors

+

In common with other websites, log files are stored on the web server saving details such as the visitor's IP address, browser type, referring page and time of visit.

+

Cookies may be used to remember visitor preferences when interacting with the website.

+

Where registration is required, the visitor's email and a username will be stored on the server.

+

How the Information is used

+

The information is used to enhance the vistor's experience when using the website to display personalised content and possibly advertising.

+

E-mail addresses will not be sold, rented or leased to 3rd parties.

+

E-mail may be sent to inform you of news of our services or offers by us or our affiliates.

+

Visitor Options

+

If you have subscribed to one of our services, you may unsubscribe by following the instructions which are included in e-mail that you receive.

+

You may be able to block cookies via your browser settings but this may prevent you from access to certain features of the website.

+

Cookies

+

Cookies are small digital signature files that are stored by your web browser that allow your preferences to be recorded when visiting the website. Also they may be used to track your return visits to the website.

+

3rd party advertising companies may also use cookies for tracking purposes.

+

Google Ads

+

Google, as a third party vendor, uses cookies to serve ads.

+

Google's use of the DART cookie enables it to serve ads to visitors based on their visit to sites they visit on the Internet.

+

Website visitors may opt out of the use of the DART cookie by visiting the Google ad and content network privacy policy.

\ No newline at end of file diff --git a/website-sveltekit/demo-data/posts/becoming-a-productive-rabbit.jpeg b/website-sveltekit/demo-data/posts/becoming-a-productive-rabbit.jpeg new file mode 100644 index 0000000..4d61051 Binary files /dev/null and b/website-sveltekit/demo-data/posts/becoming-a-productive-rabbit.jpeg differ diff --git a/website-sveltekit/demo-data/posts/becoming-a-productive-rabbit.md b/website-sveltekit/demo-data/posts/becoming-a-productive-rabbit.md new file mode 100644 index 0000000..08f0e33 --- /dev/null +++ b/website-sveltekit/demo-data/posts/becoming-a-productive-rabbit.md @@ -0,0 +1,21 @@ + + +

Rabbits are known for their quickness and agility, but did you know they can also be incredibly productive? Here are a few tips to help you become the most productive rabbit you can be:

+
    +
  1. +

    Set clear goals. Determine what you want to achieve and make a plan to reach your goals.

    +
  2. +
  3. +

    Use your natural abilities. Rabbits are quick, so use that speed to your advantage by completing tasks quickly and efficiently.

    +
  4. +
  5. +

    Stay organized. Keep your burrow neat and tidy so you can quickly find what you need when you need it.

    +
  6. +
  7. +

    Take breaks. Despite their reputation for being quick, rabbits need breaks too. Take short hops to stretch your legs and rest your mind.

    +
  8. +
  9. +

    Surround yourself with positive influences. Make friends with other productive rabbits and learn from their habits.

    +
  10. +
+

By following these tips, you'll be well on your way to becoming the most productive rabbit you can be. So, get hopping and get things done!

\ No newline at end of file diff --git a/website-sveltekit/demo-data/posts/rabbit-facts.jpeg b/website-sveltekit/demo-data/posts/rabbit-facts.jpeg new file mode 100644 index 0000000..78b08a8 Binary files /dev/null and b/website-sveltekit/demo-data/posts/rabbit-facts.jpeg differ diff --git a/website-sveltekit/demo-data/posts/rabbit-facts.md b/website-sveltekit/demo-data/posts/rabbit-facts.md new file mode 100644 index 0000000..104fad6 --- /dev/null +++ b/website-sveltekit/demo-data/posts/rabbit-facts.md @@ -0,0 +1,7 @@ + + +

Rabbits are not just cute and cuddly, they are also talented singers! These furry creatures have a unique vocalization that is surprisingly melodic. When they're happy, they'll belt out a series of melodic trills that will make even the least musical person want to join in.

+

Another mind-blowing fact about rabbits is that they are incredibly fast runners. They can reach speeds of up to 45 miles per hour, which is faster than most people can run! This makes them excellent at escaping danger and ensuring their survival.

+

Did you know that rabbits have excellent eyesight? They have 360-degree vision, which allows them to see predators coming from any direction. This is why it's so hard to sneak up on a rabbit in the wild!

+

Rabbits are also incredibly clean animals. They spend hours grooming themselves, and they'll even clean their friends to show them affection. This behavior not only helps them stay clean, but it also strengthens their bonds with one another.

+

These are just a few of the many amazing facts about rabbits. If you're a fan of these cute and cuddly creatures, be sure to share these fun facts with your friends

\ No newline at end of file diff --git a/website-sveltekit/demo-data/posts/steampunk-rabbits.jpeg b/website-sveltekit/demo-data/posts/steampunk-rabbits.jpeg new file mode 100644 index 0000000..34ed580 Binary files /dev/null and b/website-sveltekit/demo-data/posts/steampunk-rabbits.jpeg differ diff --git a/website-sveltekit/demo-data/posts/steampunk-rabbits.md b/website-sveltekit/demo-data/posts/steampunk-rabbits.md new file mode 100644 index 0000000..0d0865f --- /dev/null +++ b/website-sveltekit/demo-data/posts/steampunk-rabbits.md @@ -0,0 +1,7 @@ + + +

Steampunk rabbits, with their blend of mechanical and organic abilities, are the perfect representation of the future of work. In a world where automation and technology are constantly advancing, these unique creatures embody the perfect balance between human and machine. They possess a level of dexterity, intelligence, and problem-solving skills that allow them to take on tasks previously only performed by humans.

+

Not only do steampunk rabbits have the ability to work tirelessly without rest, but they also possess a level of creativity and innovation that is unmatched by traditional machines. Their unique design, combined with their adaptability and resourcefulness, make them the ideal candidate for a wide range of industries.

+

From manufacturing to finance, steampunk rabbits are already making a big impact in the world of work. They have the ability to learn new skills quickly and can easily adapt to new tasks and environments. They are also able to work in hazardous conditions that would be too dangerous for humans.

+

In addition to their practical benefits, steampunk rabbits also bring a level of excitement and novelty to the workplace. Their unique appearance and mechanical abilities have already captured the hearts of many and are sure to continue to do so in the future.

+

So, why are steampunk rabbits the future of work? Simply put, they offer a perfect balance of efficiency, adaptability, and creativity that is unmatched by any other form of technology. If you haven't already, it's time to embrace this unique and exciting new breed of worker.

diff --git a/website-sveltekit/package.json b/website-sveltekit/package.json new file mode 100644 index 0000000..8fb3f07 --- /dev/null +++ b/website-sveltekit/package.json @@ -0,0 +1,20 @@ +{ + "name": "frontend", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@sveltejs/adapter-auto": "^2.0.0", + "@sveltejs/kit": "^1.27.4", + "svelte": "^4.2.7", + "vite": "^4.4.2" + }, + "type": "module", + "dependencies": { + "@directus/sdk": "^13.0.2" + } +} diff --git a/website-sveltekit/src/app.html b/website-sveltekit/src/app.html new file mode 100644 index 0000000..77a5ff5 --- /dev/null +++ b/website-sveltekit/src/app.html @@ -0,0 +1,12 @@ + + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + diff --git a/website-sveltekit/src/hooks.server.js b/website-sveltekit/src/hooks.server.js new file mode 100644 index 0000000..be6801c --- /dev/null +++ b/website-sveltekit/src/hooks.server.js @@ -0,0 +1,8 @@ +export async function handle({event, resolve}) { + + return await resolve(event, { + filterSerializedResponseHeaders: (key, value) => { + return key.toLowerCase() === 'content-type' + } + }); +} \ No newline at end of file diff --git a/website-sveltekit/src/lib/directus.js b/website-sveltekit/src/lib/directus.js new file mode 100644 index 0000000..dd191f5 --- /dev/null +++ b/website-sveltekit/src/lib/directus.js @@ -0,0 +1,16 @@ +import { createDirectus, rest } from "@directus/sdk"; +import { readItems, readItem, updateItem, updateUser, createItem, deleteItem } from "@directus/sdk"; + +function getDirectusInstance(fetch) { + const directus = createDirectus(import.meta.env.VITE_APIURL, { globals: { fetch } }).with(rest()); + + directus.updateUser = async (id, query) => directus.request(updateUser(id, query)); + directus.updateItem = async (collection, id, query) => directus.request(updateItem(collection, id, query)); + directus.readItems = async (collection, query) => directus.request(readItems(collection, query)); + directus.readItem = async (collection, id, query) => directus.request(readItem(collection, id, query)); + directus.createItem = async (collection, query) => directus.request(createItem(collection, query)); + directus.deleteItem = async (collection, id) => directus.request(deleteItem(collection, id)); + + return directus; +} +export default getDirectusInstance; diff --git a/website-sveltekit/src/lib/index.js b/website-sveltekit/src/lib/index.js new file mode 100644 index 0000000..856f2b6 --- /dev/null +++ b/website-sveltekit/src/lib/index.js @@ -0,0 +1 @@ +// place files you want to import through the `$lib` alias in this folder. diff --git a/website-sveltekit/src/routes/+layout.svelte b/website-sveltekit/src/routes/+layout.svelte new file mode 100644 index 0000000..909c420 --- /dev/null +++ b/website-sveltekit/src/routes/+layout.svelte @@ -0,0 +1,9 @@ +Home +About +Code of Conduct +Privacy Policy +Blog + +
+ +
\ No newline at end of file diff --git a/website-sveltekit/src/routes/+page.js b/website-sveltekit/src/routes/+page.js new file mode 100644 index 0000000..8aeac2e --- /dev/null +++ b/website-sveltekit/src/routes/+page.js @@ -0,0 +1,8 @@ +/** @type {import('./$types').PageLoad} */ +import getDirectusInstance from '$lib/directus'; +export async function load({fetch}) { + const directus = getDirectusInstance(fetch); + return { + global: await directus.readItems('global') + }; +} \ No newline at end of file diff --git a/website-sveltekit/src/routes/+page.svelte b/website-sveltekit/src/routes/+page.svelte new file mode 100644 index 0000000..593a7ee --- /dev/null +++ b/website-sveltekit/src/routes/+page.svelte @@ -0,0 +1,8 @@ + + + +

{data.global.title}

+

{data.global.description}

\ No newline at end of file diff --git a/website-sveltekit/src/routes/[slug]/+page.js b/website-sveltekit/src/routes/[slug]/+page.js new file mode 100644 index 0000000..67dc90e --- /dev/null +++ b/website-sveltekit/src/routes/[slug]/+page.js @@ -0,0 +1,13 @@ +/** @type {import('./$types').PageLoad} */ +import { error } from '@sveltejs/kit'; +import getDirectusInstance from '$lib/directus'; +export async function load({fetch,params}) { + const directus = getDirectusInstance(fetch); + try { + return { + page: await directus.readItem('pages', params.slug) + }; + } catch (err) { + throw error(404, 'Page not found'); + } +} \ No newline at end of file diff --git a/website-sveltekit/src/routes/[slug]/+page.svelte b/website-sveltekit/src/routes/[slug]/+page.svelte new file mode 100644 index 0000000..95ba021 --- /dev/null +++ b/website-sveltekit/src/routes/[slug]/+page.svelte @@ -0,0 +1,8 @@ + + + +

{data.page.title}

+
{@html data.page.content}
\ No newline at end of file diff --git a/website-sveltekit/src/routes/blog/+page.js b/website-sveltekit/src/routes/blog/+page.js new file mode 100644 index 0000000..f0f5995 --- /dev/null +++ b/website-sveltekit/src/routes/blog/+page.js @@ -0,0 +1,11 @@ +/** @type {import('./$types').PageLoad} */ +import getDirectusInstance from '$lib/directus'; +export async function load({fetch}) { + const directus = getDirectusInstance(fetch); + return { + posts: await directus.readItems('posts', { + fields: ['slug', 'title', 'publish_date', { 'author': [ 'name' ] }], + sort: ['-publish_date'] + }) + }; +} \ No newline at end of file diff --git a/website-sveltekit/src/routes/blog/+page.svelte b/website-sveltekit/src/routes/blog/+page.svelte new file mode 100644 index 0000000..3cd1f8f --- /dev/null +++ b/website-sveltekit/src/routes/blog/+page.svelte @@ -0,0 +1,18 @@ + + +

Blog

+ diff --git a/website-sveltekit/src/routes/blog/[slug]/+page.js b/website-sveltekit/src/routes/blog/[slug]/+page.js new file mode 100644 index 0000000..c705e6f --- /dev/null +++ b/website-sveltekit/src/routes/blog/[slug]/+page.js @@ -0,0 +1,15 @@ +/** @type {import('./$types').PageLoad} */ +import { error } from "@sveltejs/kit"; +import getDirectusInstance from "$lib/directus"; +export async function load({ fetch, params }) { + const directus = getDirectusInstance(fetch); + try { + return { + post: await directus.readItem("posts", params.slug, { + fields: ["*", { "*": ["*"] }], + }), + }; + } catch (err) { + throw error(404, "Post not found"); + } +} diff --git a/website-sveltekit/src/routes/blog/[slug]/+page.svelte b/website-sveltekit/src/routes/blog/[slug]/+page.svelte new file mode 100644 index 0000000..91105b6 --- /dev/null +++ b/website-sveltekit/src/routes/blog/[slug]/+page.svelte @@ -0,0 +1,7 @@ + + +

{data.post.title}

+
{@html data.post.content}
\ No newline at end of file diff --git a/website-sveltekit/static/favicon.png b/website-sveltekit/static/favicon.png new file mode 100644 index 0000000..825b9e6 Binary files /dev/null and b/website-sveltekit/static/favicon.png differ diff --git a/website-sveltekit/svelte.config.js b/website-sveltekit/svelte.config.js new file mode 100644 index 0000000..348fa32 --- /dev/null +++ b/website-sveltekit/svelte.config.js @@ -0,0 +1,13 @@ +import adapter from '@sveltejs/adapter-auto'; + +/** @type {import('@sveltejs/kit').Config} */ +const config = { + kit: { + // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. + // If your environment is not supported or you settled on a specific environment, switch out the adapter. + // See https://kit.svelte.dev/docs/adapters for more information about adapters. + adapter: adapter() + } +}; + +export default config; diff --git a/website-sveltekit/vite.config.js b/website-sveltekit/vite.config.js new file mode 100644 index 0000000..bbf8c7d --- /dev/null +++ b/website-sveltekit/vite.config.js @@ -0,0 +1,6 @@ +import { sveltekit } from '@sveltejs/kit/vite'; +import { defineConfig } from 'vite'; + +export default defineConfig({ + plugins: [sveltekit()] +});