Blame view

doraemon/middleware/seo/index.js 443 Bytes
1 2 3 4 5 6 7 8 9 10 11 12
'use strict';

// 页面seo相关属性的配置文件
const seoMap = require('./seoConfig');

/**
 * 设置seo相关的数据,包括title, keywords, description
 * @return {Function} 中间件函数,用于给res.locals对象添加属性
 */
module.exports = () => {
    return (req, res, next) => {
        if (!req.xhr) {
郭成尧 authored
13
            Object.assign(res.locals, seoMap[req.originalUrl] || seoMap['/']);
14 15 16
        }
        next();
    };
郭成尧 authored
17
};