build(docs-infra): implement `@reviewed` tag definition (#40582)
The `@reviewed` tag can be used to specify the date when the document was last reviewed. PR Close #40582
This commit is contained in:
parent
dceede4f80
commit
d4f42b3223
|
@ -0,0 +1,6 @@
|
||||||
|
.reviewed {
|
||||||
|
color: lighten($darkgray, 10);
|
||||||
|
@include font-size(13);
|
||||||
|
font-style: italic;
|
||||||
|
text-align: right;
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
@import 'errors';
|
@import 'errors';
|
||||||
@import 'features';
|
@import 'features';
|
||||||
@import 'filetree';
|
@import 'filetree';
|
||||||
|
@import 'guides';
|
||||||
@import 'heading-anchors';
|
@import 'heading-anchors';
|
||||||
@import 'hr';
|
@import 'hr';
|
||||||
@import 'images';
|
@import 'images';
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* @reviewed <date-string>
|
||||||
|
*
|
||||||
|
* Use this tag-def to indicate the date when this document was last reviewed.
|
||||||
|
* The date-string will be passed to the `Date()` constructor.
|
||||||
|
*/
|
||||||
|
module.exports = function(createDocMessage) {
|
||||||
|
return {
|
||||||
|
name: 'reviewed',
|
||||||
|
transforms(doc, tag, value) {
|
||||||
|
if (!/^\d{4}-\d{1,2}-\d{1,2}/.test(value.trim())) {
|
||||||
|
throw new Error(createDocMessage(
|
||||||
|
`Tag Error: @${tag.tagName} tag is missing the required date in the form "yyyy-mm-dd" but got "${value}"\n`,
|
||||||
|
doc));
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
date: new Date(value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -3,12 +3,13 @@
|
||||||
{% set relativePath = doc.fileInfo.relativePath %}
|
{% set relativePath = doc.fileInfo.relativePath %}
|
||||||
{% if doc.title %}{$ ('# ' + doc.title.trim()) | marked $}{% endif %}
|
{% if doc.title %}{$ ('# ' + doc.title.trim()) | marked $}{% endif %}
|
||||||
{% if '/' in relativePath or 'docs.md' in relativePath %}
|
{% if '/' in relativePath or 'docs.md' in relativePath %}
|
||||||
<div class="github-links">
|
<div class="github-links">
|
||||||
{$ github.githubEditLink(doc, versionInfo) $}
|
{$ github.githubEditLink(doc, versionInfo) $}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{$ doc.description | marked $}
|
{$ doc.description | marked $}
|
||||||
|
{% if doc.reviewed %}<div class="reviewed">Last reviewed on {$ doc.reviewed.date.toDateString() $}</div>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue