diff --git a/Dockerfile b/Dockerfile index 90f4972..dfdef3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,12 +15,14 @@ ARG PUBLIC_ALGOLIA_ID ARG PUBLIC_FORMSPREE_ID ARG VITE_ALGOLIA_ID ARG VITE_ALGOLIA_API +ARG VITE_PUBLIC_DOMAIN ENV NODE_ENV="production" ENV PUBLIC_ALGOLIA_API=$PUBLIC_ALGOLIA_API ENV PUBLIC_ALGOLIA_ID=$PUBLIC_ALGOLIA_ID ENV PUBLIC_FORMSPREE_ID=$PUBLIC_FORMSPREE_ID ENV VITE_ALGOLIA_API=$VITE_ALGOLIA_API ENV VITE_ALGOLIA_ID=$VITE_ALGOLIA_ID +ENV VITE_PUBLIC_DOMAIN=$VITE_PUBLIC_DOMAIN # Install pnpm ARG PNPM_VERSION=8.9.0 diff --git a/package.json b/package.json index c50d1b6..adf8bce 100644 --- a/package.json +++ b/package.json @@ -1,70 +1,70 @@ { - "name": "shaniit", - "version": "0.0.1", - "private": true, - "scripts": { - "start": "node build", - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch", - "lint": "prettier --plugin-search-dir . --check . && eslint .", - "format": "prettier --plugin-search-dir . --write .", - "dev-prepare": "husky install" - }, - "devDependencies": { - "@flydotio/dockerfile": "^0.4.11", - "@portabletext/svelte": "^2.1.4", - "@sveltejs/adapter-auto": "^2.1.1", - "@sveltejs/adapter-cloudflare": "^2.3.4", - "@sveltejs/adapter-node": "^1.3.1", - "@sveltejs/kit": "^1.27.7", - "@tailwindcss/typography": "^0.5.10", - "@types/prismjs": "^1.26.3", - "autoprefixer": "^10.4.16", - "carbon-components-svelte": "^0.75.1", - "carbon-icons-svelte": "^11.4.0", - "eslint": "^8.55.0", - "eslint-config-prettier": "^8.10.0", - "eslint-plugin-svelte": "^2.35.1", - "husky": "^8.0.3", - "postcss": "^8.4.32", - "prettier": "^2.8.8", - "prettier-plugin-svelte": "^2.10.1", - "sass": "^1.69.5", - "svelte": "^3.59.2", - "svelte-check": "^3.6.2", - "tailwindcss": "^3.3.6", - "typescript": "^5.3.3", - "vite": "^4.5.1" - }, - "type": "module", - "dependencies": { - "@algolia/autocomplete-js": "^1.12.2", - "@algolia/autocomplete-theme-classic": "^1.12.2", - "@carbon/charts-svelte": "^1.13.8", - "@carbon/styles": "^1.44.0", - "@sanity/client": "^6.9.2", - "@sanity/code-input": "^4.1.1", - "@sanity/color-input": "^3.1.0", - "@sanity/icons": "^2.7.0", - "@sanity/image-url": "^1.0.2", - "@sanity/vision": "^3.21.0", - "algoliasearch": "^4.20.0", - "carbon-preprocess-svelte": "^0.9.1", - "d3": "^7.8.5", - "d3-cloud": "^1.2.7", - "d3-sankey": "^0.12.3", - "instantsearch.js": "^4.62.0", - "moment": "^2.29.4", - "prismjs": "^1.29.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-icons": "^4.12.0", - "sanity": "^3.21.0", - "sanity-plugin-asset-source-unsplash": "^1.1.2", - "sanity-plugin-graph-view": "^2.0.1", - "svelte-preprocess": "^5.1.1" - } + "name": "shaniit", + "version": "0.0.1", + "private": true, + "scripts": { + "start": "node build", + "dev": "vite dev", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json", + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch", + "lint": "prettier --plugin-search-dir . --check . && eslint .", + "format": "prettier --plugin-search-dir . --write .", + "dev-prepare": "husky install" + }, + "devDependencies": { + "@flydotio/dockerfile": "^0.4.11", + "@portabletext/svelte": "^2.1.4", + "@sveltejs/adapter-auto": "^2.1.1", + "@sveltejs/adapter-cloudflare": "^2.3.4", + "@sveltejs/adapter-node": "^1.3.1", + "@sveltejs/kit": "^1.27.7", + "@tailwindcss/typography": "^0.5.10", + "@types/prismjs": "^1.26.3", + "autoprefixer": "^10.4.16", + "carbon-components-svelte": "^0.75.1", + "carbon-icons-svelte": "^11.4.0", + "eslint": "^8.55.0", + "eslint-config-prettier": "^8.10.0", + "eslint-plugin-svelte": "^2.35.1", + "husky": "^8.0.3", + "postcss": "^8.4.32", + "prettier": "^2.8.8", + "prettier-plugin-svelte": "^2.10.1", + "sass": "^1.69.5", + "svelte": "^3.59.2", + "svelte-check": "^3.6.2", + "tailwindcss": "^3.3.6", + "typescript": "^5.3.3", + "vite": "^4.5.1" + }, + "type": "module", + "dependencies": { + "@algolia/autocomplete-js": "^1.12.2", + "@algolia/autocomplete-theme-classic": "^1.12.2", + "@carbon/charts-svelte": "^1.13.8", + "@carbon/styles": "^1.44.0", + "@sanity/client": "^6.9.2", + "@sanity/code-input": "^4.1.1", + "@sanity/color-input": "^3.1.0", + "@sanity/icons": "^2.7.0", + "@sanity/image-url": "^1.0.2", + "@sanity/vision": "^3.21.0", + "algoliasearch": "^4.20.0", + "carbon-preprocess-svelte": "^0.9.1", + "d3": "^7.8.5", + "d3-cloud": "^1.2.7", + "d3-sankey": "^0.12.3", + "instantsearch.js": "^4.62.0", + "moment": "^2.29.4", + "prismjs": "^1.29.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-icons": "^4.12.0", + "sanity": "^3.21.0", + "sanity-plugin-asset-source-unsplash": "^1.1.2", + "sanity-plugin-graph-view": "^2.0.1", + "svelte-preprocess": "^5.1.1" + } } diff --git a/src/routes/sitemap.xml/+server.ts b/src/routes/sitemap.xml/+server.ts new file mode 100644 index 0000000..674767d --- /dev/null +++ b/src/routes/sitemap.xml/+server.ts @@ -0,0 +1,140 @@ +const DOMAIN = 'https://shaniit.org'; +import { getPageData } from '$lib/sanity/query'; +type Page = { + loc: string; + changefreq: string; + priority: number; + lastmod: string; +}; +const pages = [ + { + loc: '/', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + { + loc: '/blogs', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + { + loc: '/events', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + + { + loc: '/userguides', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + + { + loc: '/faqs', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + + { + loc: '/fonts', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + { + loc: '/natural-language-processing', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + { + loc: '/terms', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + { + loc: '/about', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + + { + loc: '/donate', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + }, + { + loc: '/contact', + changefreq: 'daily', + priority: 1, + lastmod: new Date().toISOString() + } +]; + +let query = `{ + "blogs" :*[_type == "news"][0...1000]{ + "loc":slug.current, + "lastmod":_updatedAt, + }, + "events":*[_type == "events"][0...1000]{ + "loc":slug.current, + "lastmod":_updatedAt, + }, +}`; + +export async function GET() { + const { events, blogs }: { events: Page[]; blogs: Page[] } = await getPageData(query); + return new Response( + ` + + + + ${pages.map( + (page) => ` + + ${DOMAIN}${page.loc} + ${page.changefreq} + ${page.priority} + ` + )} + ${blogs.map( + (page) => ` + + ${DOMAIN}/events/${page.loc} + weekly + 0.7 + + ` + )} + ${blogs.map( + (page) => ` + + ${DOMAIN}/blogs/${page.loc} + weekly + 0.5 + + ` + )} + `.trim(), + { + headers: { + 'Content-Type': 'application/xml' + } + } + ); +} diff --git a/svelte.config.js b/svelte.config.js index ad07298..4761f01 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -4,21 +4,22 @@ import sveltePreprocess from 'svelte-preprocess'; /** @type {import('@sveltejs/kit').Config} */ const config = { - preprocess: [ - sveltePreprocess({ - scss: true - }), - optimizeImports() - ], - kit: { - adapter: adapter({ - // See below for an explanation of these options - routes: { - include: ['/*'], - exclude: [''] - } - }) - } + preprocess: [ + sveltePreprocess({ + scss: true, + preserve: ['ld+json'] + }), + optimizeImports() + ], + kit: { + adapter: adapter({ + // See below for an explanation of these options + routes: { + include: ['/*'], + exclude: [''] + } + }) + } }; export default config;