404Notice
This commit is contained in:
@@ -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
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
<div v-html="content"></div>
|
||||
</div>
|
||||
<div v-else class="text-center font-bold text-4xl font-smooth py-16 text-gray-600 ">
|
||||
404 | Page Not Found!
|
||||
loading
|
||||
</div>
|
||||
<div v-if="fileAttached">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -17,6 +17,7 @@ const { title } = Astro.props;
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script src="/js/inc.js" defer></script>
|
||||
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9252259454702469" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -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);
|
||||
|
||||
---
|
||||
<Layout title="">
|
||||
@@ -32,4 +32,3 @@ import NoticePage from "../../components/NoticePage.vue"
|
||||
<Footer />
|
||||
</Layout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user