Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Title format is not configurable

未关闭
#272 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript

调研方向

从 src/relative-time-element.ts 中 issue 所链接的标题格式化代码开始,然后检查现有的格式化选项和相关测试。定义并实现标题格式化如何复用样式设置或接受独立规则,同时保留浏览器本地时区格式化;当标题支持所请求的本地化格式时即表示完成。

由索引模型根据 Issue 内容生成。

描述

Hello, and thanks for this custom element!

I am starting to use <relative-time> in an app that supports multiple languages and users are in different countries. I started with the basics and just set the datetime attribute and inner text.

I noticed the automatic title always had short months. I tried to change it by setting formatStyle="long" and month="long" to no avail. Inspecting the source I found that titles use a fixed format:

https://github.com/github/relative-time-element/blob/7e40806f21684e46573e202527b9505e723d13e8/src/relative-time-element.ts#L116-L130

Thanks to the comment in the code above, I was able to temporarily solve for my use case by rendering the title from the server side, but that meant giving up showing the time in the timezone of the browser.

Would you consider re-using the style settings when formatting the title or provide a specific formatting rule for the title, independent from the inner text?

PS: Related, but less important, it would also be useful to add some text around the date, like title="Updated at {formatted-date-here}" (where the string "Updated at" is rendered in the correct locale on the server).

Thanks again!

主要语言
JavaScript
星标
4k
派生
194
平均合并
4 天 10 小时
30 天内合并 PR
5

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/relative-time-element 的其他 Issue

查看 github/relative-time-element 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。