南锋

南奔万里空,脱死锋镝余

将hexo部署到微信小程序

已经上线的小程序

1、小程序搜索:it前端农民工
2、扫描下方二维码

hexo部署方法

安装hexo-generator-wxapi

1
npm install hexo-generator-wxapi --save

使用方法看这里

接口配置

1、 在hexo根目录的_config.yml文件中加入一下配置,必须配

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
restful_api:
# site 可配置为数组选择性生成某些属性
# site: ['title', 'subtitle', 'description', 'author', 'since', email', 'favicon', 'avatar']
site: true # hexo.config mix theme.config
posts_size: 8 # 文章列表分页,0 表示不分页
posts_props: # 文章列表项的需要生成的属性
title: true
slug: true
date: true
updated: true
comments: true
path: true
excerpt: false
cover: true # 封面图,取文章第一张图片
content: false
keywords:
categories: true
tags: true
categories: true # 分类数据
use_category_slug: false # Use slug for filename of category data
tags: true # 标签数据
use_tag_slug: false # Use slug for filename of tag data
post: true # 文章数据
pages: false # 额外的 Hexo 页面数据, 如 About
swipers_list: [] # 生成指定的页面信息,做指定的轮播文章展示
search_all: # 配置全局搜索
enable: true
path: api/search.json
field: post
content: true

小程序配置

  • 拉取代码,将文件导入到微信开发者工具中
    1
    git clone https://github.com/Rr210/hexo-wx-api
  • 找到config文件下的config.js进行配置, 如下
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    //配置域名,域名只修改此处。可以配置为根域名 u.mr90.top/blog
    const DOMAIN = "lengmo714.top";
    const WEBSITENAME = "南锋"; //网站名称
    const ZANIMAGEURL = '../../static/images/wechat.png'; //微信鼓励的图片链接,用于个人小程序的赞赏
    const LOGO = "../../static/images/logo-icon.png"; // 网站的logo图片
    const ARTICLE_AUTHOR_NAME = "南锋" // 文章作者的名称
    const ARTICLE_AUTHOR_img = "../../static/images/author.png" // 文章作者的头像,这里是相对于文章页的地址
    //首页图标导航
    //参数说明:'name'为名称,'image'为图标路径,'url'为跳转的页面,'redirecttype'为跳转的类型,apppage为本小程序的页面,miniapp为其他微信小程序,webpage为web-view的页面
    //redirecttype 是 miniapp 就是跳转其他小程序 url 为其他小程序的页面
    //redirecttype 为 apppage 就是跳转本小程序的页面,url为本小程序的页面路径
    //'appid' 当redirecttype为miniapp时,这个值为其他微信小程序的appid,如果redirecttype为apppage,webpage时,这个值设置为空。
    //'extraData'当redirecttype为miniapp时,这个值为提交到其他微信小程序的参数,如果redirecttype为apppage,webpage时,这个值设置为空。
    const ISAD = {
    "enable": false,
    "bannerId":'adunit-c9dae21126085de9'
    }; // 是否开启广告

    const INDEXNAV = [{
    id: '1',
    name: '热门排行',
    image: '../../static/icon/index/1.png',
    url: '../hot/hot',
    redirecttype: 'apppage',
    appid: '',
    extraData: ''
    },
    {
    id: '5',
    name: '搜索文章',
    image: '../../static/icon/index/2.png',
    url: '../search/search',
    redirecttype: 'apppage',
    appid: '',
    extraData: ''
    },
    {
    id: '7',
    name: '问答讨论',
    image: '../../static/icon/index/3.png',
    url: '../feng/feng',
    redirecttype: 'apppage',
    appid: '',
    extraData: ''
    },
    {
    id: '10',
    name: '关于我们',
    image: '../../static/icon/index/4.png',
    url: '../about/about',
    redirecttype: 'apppage',
    appid: '',
    extraData: ''
    }
    ];

    export default {
    getDomain: DOMAIN,
    getWebsiteName: WEBSITENAME,
    getIndexNav: INDEXNAV,
    getZanImageUrl: ZANIMAGEURL,
    getLogo: LOGO,
    getAuthorname: ARTICLE_AUTHOR_NAME,
    getAuthorImg: ARTICLE_AUTHOR_img,
    getAd: ISAD
    }
  • 样式的配置在全局文件app.wxss文件中

小程序上传

这里就比较简单了,操作很简单,稍微百度下都会。
审核也不难,比较容易过,就是现在这个样子直接提交就能通过审核了~

希望对您有所帮助!