diff --git a/astro.config.mjs b/astro.config.mjs index ad34329..48afe22 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -8,7 +8,10 @@ import vue from "@astrojs/vue"; // https://astro.build/config +// https://astro.build/config +import partytown from "@astrojs/partytown"; + // https://astro.build/config export default defineConfig({ - integrations: [tailwind(), vue()] + integrations: [tailwind(), vue(), partytown()] }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 72016c9..d1f6d7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,24 @@ { - "name": "@example/basics", + "name": "sreechaitanyacollege.in", "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@example/basics", + "name": "sreechaitanyacollege.in", "version": "0.0.1", "dependencies": { + "@astrojs/partytown": "^1.2.1", "@astrojs/tailwind": "^2.1.3", "@astrojs/vue": "^1.2.2", + "@headlessui/vue": "^1.7.13", + "@heroicons/vue": "1.0.6", "astro": "^1.7.2", "tailwindcss": "^3.2.4", "vue": "^3.2.45" + }, + "devDependencies": { + "sass": "^1.57.1" } }, "node_modules/@ampproject/remapping": { @@ -101,6 +107,15 @@ "vfile-message": "^3.0.0" } }, + "node_modules/@astrojs/partytown": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@astrojs/partytown/-/partytown-1.2.1.tgz", + "integrity": "sha512-sFs4RKaahYOrHKy5rM6xf5xDavKpUICVxS0P0tQec5z3+FRq1Eo57MDTCx2QJoIhOHd3+/GgXDRHKWpbFI4RCw==", + "dependencies": { + "@builder.io/partytown": "^0.7.4", + "mrmime": "^1.0.0" + } + }, "node_modules/@astrojs/prism": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-1.0.2.tgz", @@ -605,6 +620,14 @@ "node": ">=6.9.0" } }, + "node_modules/@builder.io/partytown": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/@builder.io/partytown/-/partytown-0.7.6.tgz", + "integrity": "sha512-snXIGNiZpqjno3XYQN2lbBB+05hsQR/LSttbtIW1c0gmZ7Kh/DIo0YrxlDxCDulAMFPFM8J+4voLwvYepSj3sw==", + "bin": { + "partytown": "bin/partytown.cjs" + } + }, "node_modules/@emmetio/abbreviation": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.2.3.tgz", @@ -656,6 +679,25 @@ "node": ">=12" } }, + "node_modules/@headlessui/vue": { + "version": "1.7.13", + "resolved": "https://registry.npmjs.org/@headlessui/vue/-/vue-1.7.13.tgz", + "integrity": "sha512-obG5TdPdBDfs+jiA1mY29LPFqyJl93Q90EL86ontfRe1B6XvbjPkx+x1aAC5DA18bXbb0Juni1ayDbXo0w1u0A==", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/@heroicons/vue": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@heroicons/vue/-/vue-1.0.6.tgz", + "integrity": "sha512-ng2YcCQrdoQWEFpw+ipFl2rZo8mZ56v0T5+MyfQQvNqfKChwgP6DMloZLW+rl17GEcHkE3H82UTAMKBKZr4+WA==", + "peerDependencies": { + "vue": ">= 3" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -2931,6 +2973,12 @@ } ] }, + "node_modules/immutable": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", + "integrity": "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==", + "devOptional": true + }, "node_modules/import-meta-resolve": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-2.2.0.tgz", @@ -5307,6 +5355,23 @@ } ] }, + "node_modules/sass": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.62.1.tgz", + "integrity": "sha512-NHpxIzN29MXvWiuswfc1W3I0N8SXBd8UR26WntmDlRYf0bSADnwnOjsyMZ3lMezSlArD33Vs3YFhp7dWvL770A==", + "devOptional": true, + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/sass-formatter": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/sass-formatter/-/sass-formatter-0.7.5.tgz", @@ -6464,6 +6529,15 @@ "vfile-message": "^3.0.0" } }, + "@astrojs/partytown": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@astrojs/partytown/-/partytown-1.2.1.tgz", + "integrity": "sha512-sFs4RKaahYOrHKy5rM6xf5xDavKpUICVxS0P0tQec5z3+FRq1Eo57MDTCx2QJoIhOHd3+/GgXDRHKWpbFI4RCw==", + "requires": { + "@builder.io/partytown": "^0.7.4", + "mrmime": "^1.0.0" + } + }, "@astrojs/prism": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-1.0.2.tgz", @@ -6832,6 +6906,11 @@ "to-fast-properties": "^2.0.0" } }, + "@builder.io/partytown": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/@builder.io/partytown/-/partytown-0.7.6.tgz", + "integrity": "sha512-snXIGNiZpqjno3XYQN2lbBB+05hsQR/LSttbtIW1c0gmZ7Kh/DIo0YrxlDxCDulAMFPFM8J+4voLwvYepSj3sw==" + }, "@emmetio/abbreviation": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.2.3.tgz", @@ -6865,6 +6944,18 @@ "integrity": "sha512-L4jVKS82XVhw2nvzLg/19ClLWg0y27ulRwuP7lcyL6AbUWB5aPglXY3M21mauDQMDfRLs8cQmeT03r/+X3cZYQ==", "optional": true }, + "@headlessui/vue": { + "version": "1.7.13", + "resolved": "https://registry.npmjs.org/@headlessui/vue/-/vue-1.7.13.tgz", + "integrity": "sha512-obG5TdPdBDfs+jiA1mY29LPFqyJl93Q90EL86ontfRe1B6XvbjPkx+x1aAC5DA18bXbb0Juni1ayDbXo0w1u0A==", + "requires": {} + }, + "@heroicons/vue": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@heroicons/vue/-/vue-1.0.6.tgz", + "integrity": "sha512-ng2YcCQrdoQWEFpw+ipFl2rZo8mZ56v0T5+MyfQQvNqfKChwgP6DMloZLW+rl17GEcHkE3H82UTAMKBKZr4+WA==", + "requires": {} + }, "@jridgewell/gen-mapping": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", @@ -8436,6 +8527,12 @@ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, + "immutable": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.0.tgz", + "integrity": "sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg==", + "devOptional": true + }, "import-meta-resolve": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-2.2.0.tgz", @@ -9932,6 +10029,17 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, + "sass": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.62.1.tgz", + "integrity": "sha512-NHpxIzN29MXvWiuswfc1W3I0N8SXBd8UR26WntmDlRYf0bSADnwnOjsyMZ3lMezSlArD33Vs3YFhp7dWvL770A==", + "devOptional": true, + "requires": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + } + }, "sass-formatter": { "version": "0.7.5", "resolved": "https://registry.npmjs.org/sass-formatter/-/sass-formatter-0.7.5.tgz", diff --git a/package.json b/package.json index 7cfaeaf..e40712e 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "astro": "astro" }, "dependencies": { + "@astrojs/partytown": "^1.2.1", "@astrojs/tailwind": "^2.1.3", "@astrojs/vue": "^1.2.2", "@headlessui/vue": "^1.7.13", diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..ed47731 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,8 @@ +RewriteEngine On +#RewriteCond %{HTTPS} !=on +#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] +RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] +RewriteRule ^(.*)$ https://%1/$1 [R=301,L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*) /404 diff --git a/src/components/NoticeIDPage.vue b/src/components/NoticeIDPage.vue index fd1ce4b..4210cae 100644 --- a/src/components/NoticeIDPage.vue +++ b/src/components/NoticeIDPage.vue @@ -57,25 +57,14 @@ export default { this.file = this.page.attachments // console.log(this.file) this.isLoading = false - }); - fetch('https://api8.siliconpin.com/items/scc22?filter[slug][_eq]=' + path[2]) - .then((response) => { - if (response.ok) { - return response.json(); - } - // throw new Error('Something went wrong'); - }) - .then(jsonPageData => { - this.page = jsonPageData.data - console.log(this.page) - this.isLoading = false - return jsonPageData.data[0].id - } - ) + return this.page.id + }) .then((pageID) => { + console.log(pageID) fetch('https://api8.siliconpin.com/items/scc22_files_1?filter[scc22_id][_in]=' + pageID) .then(resp => resp.json()) .then(file => { + console.log(file) let attIDs = '' let t = 0 file.data.forEach(ids => { @@ -84,6 +73,7 @@ export default { t++ }); if(t>0) this.fileAttached=true + return attIDs }) .then((attIDs) => { @@ -91,6 +81,7 @@ export default { .then(resp => resp.json()) .then(file => { this.files = file.data + }) }) }) diff --git a/src/components/RoutePage.vue b/src/components/RoutePage.vue index 70ff9b0..b915363 100644 --- a/src/components/RoutePage.vue +++ b/src/components/RoutePage.vue @@ -4,7 +4,10 @@
- 404 | Page Not Found! + loading +
+
+
@@ -16,23 +19,68 @@ export default { attachment:null, content:null, isLoading: true, + files:null, + fileAttached:false } }, mounted: function () { let path=window.location.pathname.split('/'); - console.log(path[1]); - - // fetch('https://api8.siliconpin.com/items/scc22?filter[type][_eq]=notice&limit=-1') - let queryP='https://api8.siliconpin.com/items/scc22?filter[slug][_eq]='+path[1]; - fetch(queryP) + // console.log(path[1]); + if(path[1]==='notice' || path[1]==='documents' ){ + let queryP='https://api8.siliconpin.com/items/scc22?filter[type][_eq]=notice&filter[slug][_eq]='+path[2]; + fetch(queryP) .then(response => response.json()) .then(data => { - this.page = data.data[0] - this.content = this.page.content - // console.log(data) - this.isLoading = false - }) + this.page = data.data[0] + this.content = this.page.content + this.file = this.page.attachments + // console.log(this.file) + this.isLoading = false + return this.page.id + }) + .then((pageID) => { + fetch('https://api8.siliconpin.com/items/scc22_files_1?filter[scc22_id][_in]=' + pageID) + .then(resp => resp.json()) + .then(file => { + // console.log(file) + let attIDs = '' + let t = 0 + file.data.forEach(ids => { + if (t == 0) attIDs = ids.directus_files_id + else attIDs = attIDs + ',' + ids.directus_files_id + t++ + }); + if(t>0) this.fileAttached=true + return attIDs + }) + .then((attIDs) => { + fetch('https://api8.siliconpin.com/files?filter[id][_in]=' + attIDs) + .then(resp => resp.json()) + .then(file => { + this.files = file.data + console.log(this.files) + }) + }) + }) + .catch((error) => { + console.log(error) + }); + } + + else{ + // fetch('https://api8.siliconpin.com/items/scc22?filter[type][_eq]=notice&limit=-1') + let queryP='https://api8.siliconpin.com/items/scc22?filter[slug][_eq]='+path[1]; + fetch(queryP) + .then(response => response.json()) + .then(data => { + this.page = data.data[0] + this.content = this.page.content + // console.log(data) + this.isLoading = false + }) + } + } } \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 34ca8eb..3375a00 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -17,6 +17,7 @@ const { title } = Astro.props; + diff --git a/src/pages/notice/[id].astro b/src/pages/notice/404.astro similarity index 60% rename from src/pages/notice/[id].astro rename to src/pages/notice/404.astro index 58922a8..2cae896 100644 --- a/src/pages/notice/[id].astro +++ b/src/pages/notice/404.astro @@ -5,18 +5,6 @@ import MainMenu from "../../components/MainMenu.astro" import Footer from "../../components/Footer.astro" import NoticeIDPage from "../../components/NoticeIDPage.vue" -export async function getStaticPaths() { - const response = await fetch('https://api8.siliconpin.com/items/scc22?filter[status][_eq]=published&filter[type][_eq]=notice'); - const data = await response.json(); - const finalData = data.data.map((n: { slug: string | undefined; })=>{ - return {params: {id:n.slug}} - }) - return finalData; -} -const response = await fetch('https://api8.siliconpin.com/items/scc22?filter[status][_eq]=published&filter[type][_eq]=notice'); -const data = await response.json(); -const { id } = Astro.params; -const idx = data.data.findIndex((n: { slug: string | undefined; }) => n.slug ===id); --- diff --git a/src/pages/notice/index.astro b/src/pages/notice/index.astro index e408414..1831ed8 100644 --- a/src/pages/notice/index.astro +++ b/src/pages/notice/index.astro @@ -32,4 +32,3 @@ import NoticePage from "../../components/NoticePage.vue"