packages/article-skeleton/src/head.web.js
function getSectionName(article) {
  const { tiles } = article;

  if (!tiles) {
    return null;
  }

  const slices = tiles.reduce((acc, tile) => {
    acc.push(...tile.slices);
    return acc;
  }, []);
  const sections = slices.reduce((acc, slice) => {
    acc.push(...slice.sections);
    return acc;
  }, []);
  const titles = sections.map(section => section.title);

  if (titles.length === 0) {
    return null;
  }

  const nonNews = titles.filter(title => title !== "News");

  return nonNews.length ? nonNews[0] : "News";
}
function getSectionName(article) {
  const { tiles } = article;

  if (!tiles) {
    return null;
  }

  const slices = tiles.reduce((acc, tile) => {
    acc.push(...tile.slices);
    return acc;
  }, []);
  const sections = slices.reduce((acc, slice) => {
    acc.push(...slice.sections);
    return acc;
  }, []);
  const titles = sections.map(section => section.title);

  if (titles.length === 0) {
    return null;
  }

  const nonNews = titles.filter(title => title !== "News");

  return nonNews.length ? nonNews[0] : "News";
}
function getSectionName ( article ) { const { tiles } = article ; if ( ! tiles ) { return null ; } const slices = tiles . reduce ( ( acc , tile ) => { acc . push ( ... tile . slices ) ; return acc ; } , [ ] ) ; const sections = slices . reduce ( ( acc , slice ) => { acc . push ( ... slice . sections ) ; return acc ; } , [ ] ) ; const titles = sections . map ( section => section . title ) ; if ( titles . length === 0 ) { return null ; } const nonNews = titles . filter ( title => title !== "News" ) ; return nonNews . length ? nonNews [ 0 ] : "News" ; }
Get the section for an article, preferring it not to be News
Get the section for an article preferring it not to be News