guoziyun hai 11 meses
pai
achega
056d7c6f4d
Modificáronse 4 ficheiros con 34 adicións e 9 borrados
  1. 6 1
      routes/v2/album.js
  2. 25 4
      views/v2/album.ejs
  3. 1 1
      views/v2/albums.ejs
  4. 2 3
      views/v2/detail.ejs

+ 6 - 1
routes/v2/album.js

@@ -99,7 +99,6 @@ router.get('/:id', function (req, res, next) {
     let id = req.params.id;
     utils.validators.validateId(id);
 
-
     let cacheKey = `${CACHE_PREFIX}_album_${id}`;
     let htmlData = await redis.getAsync(cacheKey);
     // htmlData = null;
@@ -148,6 +147,10 @@ router.get('/:id', function (req, res, next) {
 
       const comments = await models.Comment.find({ approved: true, page: id }).sort({ createdAt: -1 });
 
+      // deeplink 相关
+      let applink = `https://art.pcoloring.com${req.originalUrl}`;
+      let downlink = `https://pcoloring.com/anc/`;
+
       let data = {
         title: doc.seoTitle,
         description: doc.seoDescription,
@@ -155,6 +158,8 @@ router.get('/:id', function (req, res, next) {
         uri: req.originalUrl,
         pageId: id,
         comments,
+        applink,
+        downlink,
       };
       // 渲染EJS模板到内存中
       res.render('v2/album', data, async (err, html) => {

+ 25 - 4
views/v2/album.ejs

@@ -4,11 +4,32 @@
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <meta name="description" content="<%= description %>">
-  <title>
-    <%= title %>
-  </title>
   <link rel="icon" href="/assets/icon/favicon.ico" type="image/x-icon">
+  <title><%= title %></title>
+
+  <meta name="description" content="<%= description %>">
+  <meta property="og:title" content="<%= title %>">
+  <meta property="og:description" content="<%= description %>">
+  <meta property="og:image" content="<%= data.cover %>">
+  <meta property="og:type" content="website">
+
+  <!-- MARK: Universal Link / Android App Link 的核心配置 -->
+  <!-- 这些 meta 标签的值应该是完整的 HTTPS 链接,Facebook 会识别并尝试拉起 App -->
+  <meta property="og:url" content="<%= applink %>" />
+  <!-- **Universal Link 路径** -->
+  <meta property="al:ios:url" content="<%= applink %>" />
+  <!-- **Universal Link 路径** -->
+  <meta property="al:ios:app_store_id" content="1575480118" /> <!-- **iOS App Store ID** -->
+  <meta property="al:ios:app_name" content="Art Number Coloring Book" /> <!-- **iOS 应用名称** -->
+
+  <meta property="al:android:package" content="com.pcoloring.art.puzzle.color.by.number" /> <!-- **Android 包名** -->
+  <meta property="al:android:url" content="<%= applink %>>" />
+  <!-- ** Universal Link 路径** -->
+  <meta property="al:android:app_name" content="Art Number Coloring Book" /> <!-- **Android 应用名称** -->
+
+  <meta name="apple-itunes-app" content="app-id=1575480118">
+  
+
   <link rel="stylesheet" href="/stylesheets/v2/styles.css">
   <style>
     h1 {

+ 1 - 1
views/v2/albums.ejs

@@ -107,7 +107,7 @@
           "url": "https://art.pcoloring.com<%= item.uri %>",
           "name": "<%= item.title %>",
           "description": "<%= item.slogon %>",
-          "image": "https://d2mb6s2cy1zg97.cloudfront.net/thumbs/coloring-page/work/480/<%= item.id %>.webp"
+          "image": "https://d2mb6s2cy1zg97.cloudfront.net/thumbs/coloring-page/album_icon/320/<%= item._id %>.webp"
         }
       }<% if(index < data.length - 1){ %>, <%}%>
     <% }); %>

+ 2 - 3
views/v2/detail.ejs

@@ -5,9 +5,8 @@
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="icon" href="/assets/icon/favicon.ico" type="image/x-icon">
-  <title>
-    <%= title %>
-  </title>
+  <title><%= title %></title>
+  
   <meta name="description" content="<%= description %>">
   <meta property="og:title" content="<%= title %>">
   <meta property="og:description" content="<%= description %>">