Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using friendly names in language navigation doesn't work #20

Open
colinmathews opened this issue Aug 21, 2017 · 1 comment
Open

Using friendly names in language navigation doesn't work #20

colinmathews opened this issue Aug 21, 2017 · 1 comment

Comments

@colinmathews
Copy link

The Slate API mentions the ability to give languages friendly names. Ergo, if you want shell Markdown formatting but want to call it "curl."

image

When I tried this in Whiteboard it didn't work. The most obvious problem was that the languages in the UI navigation looked like [object Object] instead of Node, etc. I had to do the following hacks:

In script.js I added this function:

function languageDetails(lang) {
  if (typeof(lang) === 'string') {
    return { lang, name: lang }
  }
  // If it's an object, then it's [language]: [name]
  let keys = Object.keys(lang);
  lang = keys[0];
  return { lang: lang, name: lang[lang] };
}

And then in setupLanguages I changed this line in my fork to make use of it:

languages = l.map(row => languageDetails(row).lang);

Then in index.ejs I changed the language tabs HTML to this ugly mess:

<% if (typeof(language_tabs[lang]) === 'string') { %>
  <a href="#" data-language-name="<%= language_tabs[lang] %>"><%= language_tabs[lang] %></a>
<% } else { %>
  <a href="#" data-language-name="<%= Object.keys(language_tabs[lang])[0] %>"><%= language_tabs[lang][Object.keys(language_tabs[lang])[0]] %></a>
<% } %>

Thanks!

@mikemorton
Copy link

Any chance we can get this fix merged in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants