Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于加入一言 #1009

Open
cyb1010 opened this issue Sep 20, 2023 · 2 comments
Open

关于加入一言 #1009

cyb1010 opened this issue Sep 20, 2023 · 2 comments

Comments

@cyb1010
Copy link

cyb1010 commented Sep 20, 2023

我想要给主页加入一言。

官方文档中说:

修改layout目录下的layout.ejs,在<span class="h2" id="subtitle">和<% if(is_post()) { %>之间插入如下代码......

可是 layout.ejs中并没有以上代码,我试了几个地方,也不知道应该加在哪里。求助。

@cyb1010 cyb1010 closed this as completed Oct 16, 2023
@cyb1010 cyb1010 reopened this Oct 16, 2023
@xiyuvi
Copy link
Contributor

xiyuvi commented Oct 27, 2023

你看的什么文档,首页加入一言是在_config.fluid.yml 中搜索一以下内容进行配置,fluid的配置是很灵活的,尽量不会让你修改源码实现功能

# 通过 API 接口作为首页副标题的内容,必须返回的是 JSON 格式,如果请求失败则按 text 字段显示,该功能必须先开启 typing 打字机功能
    # Subtitle of the homepage through the API, must be returned a JSON. If the request fails, it will be displayed in `text` value. This feature must first enable the typing animation
    api:
      enable: true

      # 请求地址
      # Request url
      url: "https://v1.hitokoto.cn/?c=k"

      # 请求方法
      # Request method
      # Available: GET | POST | PUT
      method: "GET"

      # 请求头
      # Request headers
      headers: {}

      # 从请求结果获取字符串的取值字段,最终必须是一个字符串,例如返回结果为 {"data": {"author": "fluid", "content": "An elegant theme"}}, 则取值字段为 ['data', 'content'];如果返回是列表则自动选择第一项
      # The value field of the string obtained from the response. For example, the response content is {"data": {"author": "fluid", "content": "An elegant theme"}}, the expected `keys: ['data','content']`; if the return is a list, the first item is automatically selected
      keys: ["hitokoto"]

@cyb1010
Copy link
Author

cyb1010 commented Oct 27, 2023

你看的什么文档,首页加入一言是在_config.fluid.yml 中搜索一以下内容进行配置,fluid的配置是很灵活的,尽量不会让你修改源码实现功能

# 通过 API 接口作为首页副标题的内容,必须返回的是 JSON 格式,如果请求失败则按 text 字段显示,该功能必须先开启 typing 打字机功能
    # Subtitle of the homepage through the API, must be returned a JSON. If the request fails, it will be displayed in `text` value. This feature must first enable the typing animation
    api:
      enable: true

      # 请求地址
      # Request url
      url: "https://v1.hitokoto.cn/?c=k"

      # 请求方法
      # Request method
      # Available: GET | POST | PUT
      method: "GET"

      # 请求头
      # Request headers
      headers: {}

      # 从请求结果获取字符串的取值字段,最终必须是一个字符串,例如返回结果为 {"data": {"author": "fluid", "content": "An elegant theme"}}, 则取值字段为 ['data', 'content'];如果返回是列表则自动选择第一项
      # The value field of the string obtained from the response. For example, the response content is {"data": {"author": "fluid", "content": "An elegant theme"}}, the expected `keys: ['data','content']`; if the return is a list, the first item is automatically selected
      keys: ["hitokoto"]

是这样的,我想要在显示一言的同时能在第二行显示来源,然后翻了 这个

由于不知道应该怎么修改 layout.ejs,我只修改了typed.ejs,加入了如下内容:

fetch('https://v1.hitokoto.cn')
.then(response => response.json())
.then(data => {
  typing('『' + data.hitokoto + '』'+'<h2>'+'</h2>' +'<h5>'+ '——' + '「' + data.from + '」' + '</h5>')
})

但是在第二行出现的时候,打字机效果的光标出现在了第二行之下。请问该如何修改啊?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants