-
(Copied from mdn/yari#3350) There are places where we want to do things depending on the type of thing a page documents. One example is a sidebar that wants to group together pages that document particular types of thing. For example, the JSRef sidebar wants to group properties and methods in separate sections: ...and the CSSRef sidebar wants to group CSS properties, at-rules, and so on in separate sections: Currently we use tags for this, but tags don't have clear semantics. For example, suppose we look for Similarly, for a tag identifying a page that documents a data type, is it Another example where page type is useful is sidebars. We've talked about having a But this idea goes beyond our current usages. If we have page types, we can also describe what sorts of things different types of pages should contain, like "every CSS property page should have a BCD table" or even "every JS class page should have a 'Constructor' section", and we can use this to lint our page's content, and potentially to build pages. Technically, as @peterbe points out in mdn/yari#3350, this basic idea is already possible, since front matter keys are exposed to JS. So what's needed is:
We also defined "guide" for pages that don't follow any particular structure. (We also wrote descriptions of what these different page types should contain: https://github.com/mdn/stumptown-content/tree/master/recipes , but that would be for the future). |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Drive-by-comment; If we do this, we should throw an error (not a flaw!) if a page-type:
- css-tt-rule-descriptor Also, if we going down this route we should bite the bullet and rewrite how the // SomeSidebar.ejs
const pageType = locale !== 'en-US ? env.doc.getParent().metadata['page-type'] : env.doc.metadata['page-type'] For ease of migration; perhaps we can write it in a very forgiving way. Example implementation: // SomeSidebar.ejs
let isCSSSelectorPage = false;
let pageType = env.doc.metadata['page-type'];
if (pageType) {
isCSSSelectorPage = pageType === 'css-selector';
} else {
// Front-matter hasn't been upgraded yet!
isCSSSelectorPage = env.doc.metadata.tags.includes("CSS Selector");
console.warn(`${env.doc.mdn_url}` lacks 'page-type' front-matter. Falling back on tags.`);
} Not sure that helps. Perhaps it's "obvious" but still felt it worth pointing out. |
Beta Was this translation helpful? Give feedback.
-
FWIW Yes, absolutely to all.
Somewhere today I suggested that sidebars should be added via frontmatter rather than macro - my logic being that something like
Arguably that is not needed if sidebars are associated with content types. |
Beta Was this translation helpful? Give feedback.
-
[Not sure how github discussions work: it looks that a question is asked in the initial entry, then people are proposing answers, the actual discussions happen in replies of these, and the answers get updates; people also vote for the proposed answered that are ordered by votes by default. Finally an answer is chosen as the answer and the discussion is close. A kind of StackOverflow] I'm in favour of having Rationale for
|
Beta Was this translation helpful? Give feedback.
-
A |
Beta Was this translation helpful? Give feedback.
[Not sure how github discussions work: it looks that a question is asked in the initial entry, then people are proposing answers, the actual discussions happen in replies of these, and the answers get updates; people also vote for the proposed answered that are ordered by votes by default. Finally an answer is chosen as the answer and the discussion is close. A kind of StackOverflow]
I'm in favour of having
page-type:
in front-matter.Rationale for
page-type:
I see having quite a few advantages of having a
page-type:
directive in front-matter: