diff --git a/astro.config.mjs b/astro.config.mjs index eef063f..834aefd 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -6,9 +6,12 @@ import vercel from "@astrojs/vercel/serverless"; import webVitals from "@astrojs/web-vitals"; +import sitemap from "@astrojs/sitemap"; + // https://astro.build/config export default defineConfig({ - integrations: [db(), tailwind(), react(), webVitals()], + integrations: [db(), tailwind(), react(), webVitals(), sitemap()], + site: 'https://wix.ro', output: "server", adapter: vercel() }); \ No newline at end of file diff --git a/db/config.ts b/db/config.ts index a084cf5..21c08d7 100644 --- a/db/config.ts +++ b/db/config.ts @@ -19,7 +19,7 @@ const Session = defineTable({ const Post = defineTable({ columns: { id: column.number({ primaryKey: true }), - userId: column.text({ references: () => User.columns.id }), + userId: column.text({ optional: false, references: () => User.columns.id }), // userId: column.text({ optional: false, references: () => User.columns.id }), title: column.text(), description: column.text(), diff --git a/db/seed.ts b/db/seed.ts index b3958df..63c9987 100644 --- a/db/seed.ts +++ b/db/seed.ts @@ -4,18 +4,29 @@ export default async function seed() { await db.insert(User).values([ { id: "user_id_1", - username: "user1", - password: - "$argon2id$v=19$m=19456,t=2,p=1$AC5gMGrqxRKrco6ITV7PiQ$zjiUdOTviT0EtitFcgIrOLOye2W5/yYgyoVNMla3PH4", + username: "admin", + password: "root", }, ]) await db.insert(Post).values([ { + id: 1, userId: "user_id_1", - title: "Google1", - description: - "I found this cool site that can let you say anything you want without accountability!", - link: "https://123.com/", + title: "mat", + description: "nat", + link: "https://asda.com/", }, ]) + // const queries = [] + + // for (let i = 0; i < 25; i++) { + // queries.push( + // db.insert(Post).values({ + // title: `Test title ${i}`, + // description: `Test description ${i}`, + // link: `https://test.com/${i}`, + // }), + // ) + // } + // await db.batch(queries) } diff --git a/package-lock.json b/package-lock.json index cb3eb42..babe808 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@astrojs/check": "^0.9.3", "@astrojs/db": "^0.14.1", "@astrojs/react": "^3.6.2", + "@astrojs/sitemap": "^3.1.6", "@astrojs/tailwind": "^5.1.0", "@astrojs/vercel": "^7.8.0", "@astrojs/web-vitals": "^3.0.0", @@ -333,6 +334,17 @@ "react-dom": "^17.0.2 || ^18.0.0 || ^19.0.0-beta" } }, + "node_modules/@astrojs/sitemap": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/@astrojs/sitemap/-/sitemap-3.1.6.tgz", + "integrity": "sha512-1Qp2NvAzVImqA6y+LubKi1DVhve/hXXgFvB0szxiipzh7BvtuKe4oJJ9dXSqaubaTkt4nMa6dv6RCCAYeB6xaQ==", + "license": "MIT", + "dependencies": { + "sitemap": "^7.1.2", + "stream-replace-string": "^2.0.0", + "zod": "^3.23.8" + } + }, "node_modules/@astrojs/studio": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@astrojs/studio/-/studio-0.1.1.tgz", @@ -2920,6 +2932,15 @@ "@types/react": "*" } }, + "node_modules/@types/sax": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/sax/-/sax-1.2.7.tgz", + "integrity": "sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -8355,6 +8376,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/sax": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", + "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "license": "ISC" + }, "node_modules/scheduler": { "version": "0.23.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", @@ -8495,6 +8522,31 @@ "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", "license": "MIT" }, + "node_modules/sitemap": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/sitemap/-/sitemap-7.1.2.tgz", + "integrity": "sha512-ARCqzHJ0p4gWt+j7NlU5eDlIO9+Rkr/JhPFZKKQ1l5GCus7rJH4UdrlVAh0xC/gDS/Qir2UMxqYNHtsKr2rpCw==", + "license": "MIT", + "dependencies": { + "@types/node": "^17.0.5", + "@types/sax": "^1.2.1", + "arg": "^5.0.0", + "sax": "^1.2.4" + }, + "bin": { + "sitemap": "dist/cli.js" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=5.6.0" + } + }, + "node_modules/sitemap/node_modules/@types/node": { + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", + "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", + "license": "MIT" + }, "node_modules/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -8532,6 +8584,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/stream-replace-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/stream-replace-string/-/stream-replace-string-2.0.0.tgz", + "integrity": "sha512-TlnjJ1C0QrmxRNrON00JvaFFlNh5TTG00APw23j74ET7gkQpTASi6/L2fuiav8pzK715HXtUeClpBTw2NPSn6w==", + "license": "MIT" + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", diff --git a/package.json b/package.json index 0f02d01..2a51c85 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@astrojs/check": "^0.9.3", "@astrojs/db": "^0.14.1", "@astrojs/react": "^3.6.2", + "@astrojs/sitemap": "^3.1.6", "@astrojs/tailwind": "^5.1.0", "@astrojs/vercel": "^7.8.0", "@astrojs/web-vitals": "^3.0.0", diff --git a/public/favicon.svg b/public/favicon.svg index f157bd1..0bc673d 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1,9 +1,4 @@ - + \ No newline at end of file diff --git a/public/images/ogImage.png b/public/images/ogImage.png new file mode 100644 index 0000000..f3911d0 Binary files /dev/null and b/public/images/ogImage.png differ diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 9815d34..b12e0ac 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -2,6 +2,28 @@ import Logo from "@/components/Logo.astro" const user = Astro.locals.user + +function formatCanonicalURL(url: string | URL) { + const path = url.toString() + const hasQueryParams = path.includes("?") + if (hasQueryParams) { + path.replace(/\/?$/, "") + } + return path.replace(/\/?$/, hasQueryParams ? "" : "/") +} + +const { title, description } = Astro.props + +// const title = "12 шагов: группы, материалы и проекты." +// const description = "" +const author = "@legion_free" +const ogImage = `${Astro.site}images/ogImage.png` + +const finalDesc = + description || + "Группы разных форматов, материалы и проекты, которые связанны с 12 шагами и принципами. 12x12" + +const canonicalURL = new URL(Astro.url.pathname, Astro.site) --- @@ -10,7 +32,30 @@ const user = Astro.locals.user -