Skip to content

Commit 8c20086

Browse files
committed
Add parent relationship to deprecations to allow grouping in the UI,
especially in the index - Added `since` to the metadata display since I felt it was missing especially on the id route - Made id in the metadata display link to the individual id page to expose those URLs - Added some info to the README about the new relationship but also about adding deprecation guides
1 parent 1d33ca7 commit 8c20086

File tree

6 files changed

+55
-3
lines changed

6 files changed

+55
-3
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,27 @@
55

66
This is the app that serves https://deprecations.emberjs.com/
77

8+
## Linking to deprecations
9+
10+
You can link to a specific deprecation by using the ID of the deprecation. For example, to link to the deprecation with the ID `my-old-api`, you can use the following URL:
11+
`https://deprecations.emberjs.com/id/my-old-api`. These URLs can be generated in advance of adding the deprecation guide, when the deprecation lands in the code.
12+
When adding a deprecation the filename should match the ID of the deprecation, or the `displayId` should be specified in the frontmatter.
13+
814
## Adding new deprecations
915

1016
The [content](https://github.com/ember-learn/deprecation-app/tree/main/content/) folder contains all the deprecations that are listed by the website. To add a new deprecation, add it to the appropriate folder by creating a new file. The content of the file needs to follow a specific format for the app to work. You can see [this sample](https://raw.githubusercontent.com/ember-learn/deprecation-app/main/content/ember/v3/getting-the-each-property.md) for reference.
1117

18+
### Frontmatter
19+
20+
#### Grouping deprecations
21+
22+
```markdown
23+
parent: deprecation-id
24+
```
25+
26+
Can be used to nest deprecations under a parent grouping for the purpose of the UI. The deprecations will still be available via the direct ID URLs.
27+
28+
1229
## Prerequisites
1330

1431
You will need the following things properly installed on your computer.

app/components/deprecation-article.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import Component from '@glimmer/component';
2+
import { tracked } from '@glimmer/tracking';
3+
import { action } from '@ember/object';
24
export default class DeprecationArticle extends Component {
5+
@tracked showChildDeprecations = false;
6+
37
get idForTitle() {
48
return `toc_${this.args.model.title}`;
59
}
610

711
get idForUntil() {
812
return `toc_until-${this.args.model.until}`;
913
}
14+
15+
@action
16+
toggleChildDeprecations() {
17+
this.showChildDeprecations = !this.showChildDeprecations;
18+
}
1019
}

app/models/content.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Model, { attr } from '@ember-data/model';
1+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
22

33
export default class ContentModel extends Model {
44
@attr content;
@@ -7,6 +7,8 @@ export default class ContentModel extends Model {
77
@attr since;
88
@attr anchor;
99
@attr displayId;
10+
@belongsTo('content', { inverse: 'children', async: false }) parent;
11+
@hasMany('content', { inverse: 'parent', async: false }) children;
1012

1113
// v1 has different meta, so conditionally render it
1214
get renderUntil() {

app/templates/components/deprecation-article.hbs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@
33
<div class="my-2">
44
{{#if @model.renderUntil}}
55
<div><span class="bold">until: </span>{{@model.until}}</div>
6-
<div><span class="bold">id: </span>{{or @model.displayId @model.id}}</div>
6+
<div><span class="bold">since: </span>{{@model.since}}</div>
7+
<div><span class="bold">id: </span><LinkTo @route="id" @model={{@model.id}}>{{or @model.displayId @model.id}}</LinkTo></div>
8+
{{/if}}
9+
{{#if @model.parent}}
10+
<div><span class="bold">included in: </span><LinkTo @route="id" @model={{@model.parent.id}}>{{or @model.parent.displayId @model.parent.id}}</LinkTo> </div>
11+
{{/if}}
12+
{{#if @model.children.length}}
13+
<div><span class="bold">includes: </span> {{@model.children.length}} deprecations <button type="button" {{on "click" this.toggleChildDeprecations}}>{{(if this.showChildDeprecations 'Collapse all' 'Expand all')}}</button></div>
714
{{/if}}
815
</div>
16+
{{#if this.showChildDeprecations}}
17+
{{#each @model.children as |child|}}
18+
<DeprecationArticle @model={{child}}>
19+
<h3>
20+
{{markdown-to-html
21+
child.title
22+
extensions="no-wrapper"
23+
tagName=""
24+
}}
25+
</h3>
26+
</DeprecationArticle>
27+
{{/each}}
28+
{{/if}}
929
<section>
1030
{{markdown-to-html @model.content}}
1131
</section>
12-
</div>
32+
</div>

app/utils/process-results.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const GLIMMER = 'Glimmer Internals';
55

66
export default function processResults(query) {
77
let results = query.toArray().reduce((results, item) => {
8+
if (item.parent) {
9+
return results;
10+
}
811
let since = results.find((result) => result.since === item.since);
912
if (!since) {
1013
since = { since: item.since, contents: [] };

lib/content-docs-generator/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const jsonTrees = contentFolders.map(
2626
(type) =>
2727
new StaticSiteJson(`content/${type}`, {
2828
attributes: ['title', 'since', 'until', 'anchor', 'displayId'],
29+
references: [{ name: 'parent', type: 'content' }],
2930
type: 'contents',
3031
collate: true,
3132
collationFileName: `${type.replace(/\//, '-')}.x.json`,

0 commit comments

Comments
 (0)