-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CMS): dynamically site details are loaded !
- Loading branch information
Showing
4 changed files
with
105 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {defineType, defineField, defineArrayMember} from 'sanity' | ||
|
||
export const detail = defineType({ | ||
type: 'document', | ||
name: 'detail', | ||
fields: [ | ||
defineField({ | ||
type: 'string', | ||
name: 'SiteName', | ||
}), | ||
defineField({ | ||
type: 'string', | ||
name: 'Slogans', | ||
}), | ||
defineField({ | ||
type: 'string', | ||
name: 'Telephone', | ||
}), | ||
defineField({ | ||
type: 'string', | ||
name: 'Email', | ||
}), | ||
defineField({ | ||
type: 'string', | ||
name: 'Address', | ||
}), | ||
defineField({ | ||
type: 'string', | ||
name: 'Mobile', | ||
}), | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import { author } from "./author"; | ||
import { blogPost } from "./blogPost"; | ||
import { product } from "./product"; | ||
import { productCategory } from "./productCategory"; | ||
import { variant } from "./variant"; | ||
import {author} from './author' | ||
import {blogPost} from './blogPost' | ||
import {product} from './product' | ||
import {productCategory} from './productCategory' | ||
import {variant} from './variant' | ||
import {detail} from './detail' | ||
|
||
export const schemaTypes = [ | ||
author, | ||
blogPost, | ||
product, | ||
productCategory, | ||
variant, | ||
]; | ||
export const schemaTypes = [author, detail, blogPost, product, productCategory, variant] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>FOODIE | Home</title> | ||
<title id="title">FOODIE | Home</title> | ||
<link rel="icon" href="/favicon.ico" type="image/x-icon" /> | ||
<link rel="stylesheet" href="./styles/style.css" /> | ||
<link rel="stylesheet" href="./styles/menu.css" /> | ||
|
@@ -14,8 +14,8 @@ | |
<!-- menu and header --> | ||
<header> | ||
<div class="logo"> | ||
<h2>FOODIE</h2> | ||
<h4>MENU</h4> | ||
<h2 id="FsiteName">FOODIE</h2> | ||
<h4 id="SsiteName">MENU</h4> | ||
</div> | ||
<nav> | ||
<a href="#" class="active_tab">home</a> | ||
|
@@ -60,19 +60,22 @@ <h4>MENU</h4> | |
<hr style="width: 205px; margin-block: 0.5rem 1.5rem" /> | ||
<span style="z-index: 99"> | ||
<a href="#" | ||
><span style="color: red; font-weight: bolder">Tel:</span>+91 | ||
7339677034</a | ||
><span style="color: red; font-weight: bolder">Tel:</span><span id="tel">+91 | ||
7339677034</span></a | ||
> | ||
<a href="#" | ||
><span style="color: red; font-weight: bolder">Mob:</span>+91 | ||
733-967-7034</a | ||
><span style="color: red; font-weight: bolder">Mob:</span> | ||
<span id="mob"></span> | ||
</a | ||
> | ||
<a href="#" | ||
><span style="color: red; font-weight: bolder">E-Mail:</span | ||
>[email protected]</a | ||
><span style="color: red; font-weight: bolder">E-Mail:</span | ||
> | ||
<span id="email">[email protected]</span> | ||
</a | ||
> | ||
</span> | ||
<address> | ||
<address id="address"> | ||
11/12,RZZ Road, ambur - 635810, Vellore District, TamilNadu, India. | ||
</address> | ||
</footer> | ||
|
@@ -81,19 +84,20 @@ <h4>MENU</h4> | |
<section class="dev"> | ||
<span>Developed</span> By | ||
<h2> | ||
<a href="mailto:[email protected]">Raiyan Ahmed </a> | ||
<a href="https://raiyanu.github.io/lp">Raiyan Ahmed </a> | ||
</h2> | ||
<a href="tel:+91 7339677034" | ||
><span style="color: darkgreen; font-weight: bolder">Tel:</span> | ||
+91 7339677034 </a | ||
> | ||
<a href="#" | ||
<a href="mailto:[email protected]" | ||
><span style="color: darkgreen; font-weight: bolder">E-Mail:</span> | ||
[email protected] </a | ||
> | ||
</section> | ||
|
||
<!-- for qr code --> | ||
<script src="./js/cms.js"></script> | ||
<script type="module" src="./js/content-loader.js"></script> | ||
<script src="./js/qrcode.min.js"></script> | ||
<script src="./js/qrcode.min-init.js"></script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const fetchSiteDetails = async () => { | ||
try { | ||
const res = await fetch( | ||
"https://nxiwlt7k.api.sanity.io/v2022-03-07/data/query/production?query=*%5B_type%3D%3D%22detail%22%5D%5B0%5D" | ||
); | ||
const data = await res.json(); | ||
console.log("data : ", data); | ||
return data; | ||
} catch (error) { | ||
console.error(error); | ||
console.error("File: js/cms.js"); | ||
console.error("Error: Error in cms.js file"); | ||
} | ||
}; | ||
|
||
const useDetails = async () => { | ||
const data = await fetchSiteDetails(); | ||
try { | ||
const details = { | ||
SiteName: data.result.SiteName, | ||
Slogans: data.result.Slogans, | ||
Email: data.result.Email, | ||
Telephone: data.result.Telephone, | ||
Mobile: data.result.Mobile, | ||
Address: data.result.Address, | ||
}; | ||
console.table(details); | ||
|
||
document.getElementById("title").innerText = | ||
`${details.SiteName}`.toUpperCase() + " | Home"; | ||
const siteFirstName = `${details.SiteName}`.split(" ")[0].toLowerCase(); | ||
const siteSecondName = `${details.SiteName}`.split(" ")[1].toLowerCase(); | ||
|
||
document.getElementById("FsiteName").innerText = | ||
siteFirstName.toUpperCase(); | ||
document.getElementById("SsiteName").innerText = | ||
siteSecondName.toUpperCase(); | ||
|
||
document.getElementById("mob").innerText = details.Mobile; | ||
document.getElementById("tel").innerText = details.Telephone; | ||
document.getElementById("email").innerText = details.Email; | ||
document.getElementById("address").innerText = details.Address; | ||
} catch (error) { | ||
console.error(error); | ||
console.error("File: js/cms.js"); | ||
console.error("Error: Error in cms.js file"); | ||
} | ||
}; | ||
|
||
useDetails(); |