這是 Wix Studio 挑戰賽:社群版的投稿內容。
Latio Team 是一個為拉丁美洲的技術建構者建立的社區,它是一個在參加黑客馬拉松時參與、學習、成長和聯繫的地方。社群頁麵包括以下功能:
專案連結:https://fredoist.wixstudio.io/latio-team
首頁:
人才庫:
求職板和貼文
黑客馬拉松列表:
連接:
會員簡介:
工作查詢表格和清單:
如果您已經了解 JavaScript,那麼使用 Wix 的 Studio 和 Velo API 進行建置非常容易。
Velo API 的所有文件都清晰且非常完整,而且 Wix Studio 內的編輯器具有一些很棒的自動完成功能,非常易於使用。一旦開始建置和測試編輯器,您就會了解它的工作原理,並且可以快速實現新的 API。
另外一點,Wix 的模板可以讓您非常快速地建立一個令人驚嘆的網站,設計會適應您添加的每個新應用程式元素,這非常酷,因為您不需要接觸其他任何東西。
這是一些功能的程式碼區塊,以便您可以複製它們:
職缺
import { Permissions, webMethod } from "wix-web-module"; import { getJSON } from "wix-fetch"; const formatPrice = (p) => new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: p < 1 ? 3 : 1, }).format(Number(p)); // GET call using getJSON export const getJobs = webMethod(Permissions.Anyone, async () => { const response = await getJSON( "https://remoteok.com/api", ); const jobs = response.slice(1).map(job => { job._id = job.id; job.salary_range = `$ ${formatPrice(job.salary_min)}-${formatPrice(job.salary_max)}` job.company_logo = job.company_logo ? `https://remoteok.com/cdn-cgi/image/format=auto,fit=contain,width=100,height=100,quality=50/${job.company_logo}` : null; job.logo = job.logo ? `https://remoteok.com/cdn-cgi/image/format=auto,fit=contain,width=100,height=100,quality=50/${job.logo}` : null; job.image = job.company_logo ?? job.logo ?? `https://ui-avatars.com/api/?name=${job.company}` return job; }) return jobs; });
職位頁面
import { ok, notFound, WixRouterSitemapEntry } from "wix-router"; import { getJobs } from "backend/fetch-jobs.web" export async function job_Router(request) { // Get item name from URL request const slug = request.path[0]; // Get the item data by name const jobs = await getJobs(); const data = jobs.filter(job => job.slug === slug) if (data.length) { const job = data[0]; // Define SEO tags const seoData = { title: job.position, description: "This is a description of " + job.position + " page", noIndex: false, metaTags: [{ "property": "og:title", "content": job.position }, ] }; // Render item page return ok("job-page", job, seoData); } // Return 404 if item is not found return notFound(); } export async function job_SiteMap(sitemapRequest) { const jobs = await getJobs() // Convert the data to site map entries const siteMapEntries = jobs.map((job) => { const data = job; const entry = new WixRouterSitemapEntry(job.slug); entry.pageName = "job-page"; // The name of the page in the Wix editor to render entry.url = "/job/" + job.slug; // Relative URL of the page entry.title = data.position; // For better SEO - Help Google return entry; }); // Return the site map entries return siteMapEntries; }
寄詢問給任何會員
import { Permissions, webMethod } from "wix-web-module"; import wixData from "wix-data"; export const sendInquiry = webMethod( Permissions.Anyone, async (username, email, details, budget) => { const results = await wixData.query("Members/PrivateMembersData").eq('slug', username).find() const member = results.items.length > 0 ? results.items[0] : null; if(member) { const memberId = member._id; const result = await wixData.save("WorkInquiries", { recipientId: memberId, contactEmail: email, details, budget }) if(result) { return true } } return false; } );
取得會員查詢
import { Permissions, webMethod } from "wix-web-module"; import { query } from "wix-data"; import { currentMember } from "wix-members-backend" export const getInquiries = webMethod( Permissions.SiteMember, async () => { const member = await currentMember.getMember(); const data = await query("WorkInquiries").eq('recipientId', member._id).find(); return data.items; } );
以上是Latio Team:由技術駭客共同建構的社區的詳細內容。更多資訊請關注PHP中文網其他相關文章!