| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import { randomRange, log10 } from '../utils/misc'
- import murmurhash from 'murmurhash'
- export const genDocumentHeadData = (input: {
- ctx: any
- catName?: string
- }) => {
- const { ctx, catName } = input || {}
- const canonical: string = process.server ? `https://${ctx.req.headers.host}${ctx.req.url}` : location && location.href
- let title: string
- let keywords: string
- let descrption: string
- if (catName) {
- title = `${catName} 软件、网站、APP、小程序开发及SaaS、PaaS、IaaS、API服务平台-开发屋`
- keywords = `${catName}软件开发,${catName}APP开发,${catName}小程序开发,${catName}SaaS服务商`
- descrption = `开发屋为${catName}中小型企业企业提供各行业软件、APP、小程序开发服务,并整合开发项目所需的各种SaaS、PaaS,LaaS以及API服务商供选择,全程解决开发需求!`
- } else {
- title = '开发屋-提供网站建设、APP软件、小程序开发及SaaS、PasS、IaaS服务'
- keywords = '网站开发, 软件APP开发, SaaS, PaaS'
- descrption = '开发屋为企业提供行业内领先的技术解决方案,包括行业定制化SaaS、PasS、API数据接口服务以及技术组织,保障企业在降低人力开发成本的同时,得到优质的项目开发实力。'
- }
- return {
- title,
- keywords,
- descrption,
- canonical
- }
- }
- const scoreSubCatItem = ({path, topCatId, subCatId}) => {
- const uni = murmurhash.v3(path)
- const isRoot = path === '/'
- return (item: any, idx: number) => {
- let score = 0
- if (topCatId && item.parent_id === topCatId) {
- score += 100
- }
- if (subCatId && item.cat_id === subCatId) {
- score -= 100
- }
- if (!isRoot && !score) {
- score += log10(Math.abs(uni - murmurhash.v3(item.cat_id)))
- }
- return Object.assign({}, item, {
- _score: score
- })
- }
- }
- const genFooterLinkItem = (name: string, hashId: string) => {
- return {
- name: `${name}技术开发`,
- url: `/c/${hashId}`
- }
- }
- export const genDocumentFooterData = (input: {
- ctx: any
- classes: any[]
- topCatId?: string
- subCatId?: string
- }) => {
- const { ctx, classes, topCatId, subCatId } = input || {}
- const host = (process.server ? ctx.req.headers.host : location.host) || ''
- const path = process.server ? ctx.req.url : location.pathname || '/'
- const baseLink = host && host.indexOf('local') > -1 ? `http://${host}` : `https://${host}`
- const link = [{
- name: '热门领域技术解决方案',
- data: classes.map(topCat => genFooterLinkItem(topCat.name, topCat.hash_id))
- }, {
- name: '细分领域技术解决方案',
- data: classes
- .flatMap(topCat => topCat.categories || [])
- .map(scoreSubCatItem({path, topCatId, subCatId}))
- .sort((a, b) => b._score - a._score)
- .slice(0, randomRange(20, 30))
- .map(cat => genFooterLinkItem(cat.name, cat.cat_id))
- }]
- return {
- baseLink,
- link
- }
- }
|