1

In the open source example http://www.telesc.pe/, how do I remove digest and daily view items from the view menu? Do I need to modify telescope-base?

gsrivast
  • 141
  • 1
  • 8

2 Answers2

2

You need to create a new package to hold your customizations. You can look at the Telescope documentation, look at existing theme packages such as base and hubble, or copy and adapt the telescope-blank package.

Once you have your new package, you can simply overwrite the viewNav menu. For example:

viewNav = [
  {
    route: 'posts_top',
    label: 'top'
  },
  {
    route: 'posts_new',
    label: 'new'
  },
  {
    route: 'posts_best',
    label: 'best'
  }
];

The daily view is provided by another package, telescope-daily, so you'll need to remove it from the app if you don't want to use it:

meteor remove telescope-daily

(Note that the digest view will also be extracted out as its own package eventually, but right now it's still part of the core)

Sacha
  • 1,987
  • 1
  • 24
  • 41
0

You can try this :

Create a config.js under client/ and put the following code inside :

while(viewNav.length > 0){
  viewNav.pop();
}

viewNav.push({
  route: 'posts_top',
  label: 'Top'
});
// etc...

This will load after telescope-base which is responsible for exporting viewNav an array used to control which items are inserted in the menu.

saimeunt
  • 22,666
  • 2
  • 56
  • 61
  • 1
    The code is correct, but you should try not to touch any core files when customizing the app, otherwise that will make it harder to merge in new updates in the future. – Sacha Dec 06 '14 at 04:28
  • Also, if you want to empty `viewNav` couldn't you just do `viewNav = []`? – Sacha Dec 06 '14 at 04:35
  • Interestingly, exported symbols from packages are not lvalues, meaning they cannot be reassigned like you suggested. Good point about not messing with the core app code and put every modifications in a separate package. – saimeunt Dec 06 '14 at 05:47
  • I just tested it and `viewNav = []` seems to work as far as I can tell? – Sacha Dec 06 '14 at 07:42