add html meta generator

This commit is contained in:
aichy126 2023-01-30 15:49:53 +08:00
parent b361bbb486
commit 011c992570
5 changed files with 137 additions and 3 deletions

View File

@ -2911,6 +2911,45 @@ const docTemplate = `{
}
}
},
"/answer/api/v1/post/render": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "render post content",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Upload"
],
"summary": "render post content",
"parameters": [
{
"description": "PostRenderReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.PostRenderReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/answer/api/v1/question": {
"put": {
"security": [
@ -6589,6 +6628,14 @@ const docTemplate = `{
}
}
},
"schema.PostRenderReq": {
"type": "object",
"properties": {
"content": {
"type": "string"
}
}
},
"schema.QuestionAdd": {
"type": "object",
"required": [
@ -6669,6 +6716,9 @@ const docTemplate = `{
"collection_count": {
"type": "integer"
},
"created_at": {
"type": "integer"
},
"description": {
"type": "string"
},

View File

@ -2899,6 +2899,45 @@
}
}
},
"/answer/api/v1/post/render": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "render post content",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Upload"
],
"summary": "render post content",
"parameters": [
{
"description": "PostRenderReq",
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schema.PostRenderReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.RespBody"
}
}
}
}
},
"/answer/api/v1/question": {
"put": {
"security": [
@ -6577,6 +6616,14 @@
}
}
},
"schema.PostRenderReq": {
"type": "object",
"properties": {
"content": {
"type": "string"
}
}
},
"schema.QuestionAdd": {
"type": "object",
"required": [
@ -6657,6 +6704,9 @@
"collection_count": {
"type": "integer"
},
"created_at": {
"type": "integer"
},
"description": {
"type": "string"
},

View File

@ -976,6 +976,11 @@ definitions:
type:
type: string
type: object
schema.PostRenderReq:
properties:
content:
type: string
type: object
schema.QuestionAdd:
properties:
content:
@ -1036,6 +1041,8 @@ definitions:
type: integer
collection_count:
type: integer
created_at:
type: integer
description:
type: string
follow_count:
@ -3684,6 +3691,30 @@ paths:
summary: user's votes
tags:
- Activity
/answer/api/v1/post/render:
post:
consumes:
- application/json
description: render post content
parameters:
- description: PostRenderReq
in: body
name: data
required: true
schema:
$ref: '#/definitions/schema.PostRenderReq'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.RespBody'
security:
- ApiKeyAuth: []
summary: render post content
tags:
- Upload
/answer/api/v1/question:
delete:
consumes:

View File

@ -25,6 +25,7 @@ import (
type TemplateController struct {
scriptPath string
cssPath string
Version string
templateRenderController *templaterender.TemplateRenderController
siteInfoService *siteinfo_common.SiteInfoCommonService
}
@ -38,6 +39,7 @@ func NewTemplateController(
return &TemplateController{
scriptPath: script,
cssPath: css,
Version: constant.Version,
templateRenderController: templateRenderController,
siteInfoService: siteInfoService,
}
@ -437,6 +439,7 @@ func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteI
data["HeadCode"] = siteInfo.CustomCssHtml.CustomHead
data["HeaderCode"] = siteInfo.CustomCssHtml.CustomHeader
data["FooterCode"] = siteInfo.CustomCssHtml.CustomFooter
data["Version"] = tc.Version
_, ok := data["path"]
if !ok {
data["path"] = ""

View File

@ -6,9 +6,9 @@
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>{{.title}}</title>
<meta name="description" content="{{.description}}" data-rh="true" />
{{if .keywords }}
<meta name="keywords" content="{{.keywords}}" data-rh="true" />
{{end}}
<meta name="generator" content="Answer {{.Version}} - https://github.com/answerdev/answer">
{{if .keywords }}<meta name="keywords" content="{{.keywords}}" data-rh="true" />{{end}}
<link rel="canonical" href="{{.siteinfo.Canonical}}" />
<link rel="manifest" href="/manifest.json" />
<link href="{{.cssPath}}" rel="stylesheet" />