Display aliases below the note title

My most common use case is for medical terms, which often have multiple synonyms:

I recently replaced this with an approach using Bases. See below for the Dataview approach.

Bases approach

This requires a simple Bases setup using a list view. You may replace note.aliases with any formula to display the aliases — for example, as a comma-separated list or filtered aliases (Filtering Aliases: Removing Duplicates and Singular/Plural Forms):

  - type: list
    name: Alias line
    filters:
      and:
        - file == this.file
    order:
      - note.aliases
    markers: none

Some CSS is also needed to hide unnecessary Bases UI elements and display only the alias. Note that minor adjustments may be needed depending on your theme or other active CSS snippets:

/* Removing space after note inline title when followed by alias line. */
body:has(span.bases-embed[src*="Alias line"]) .inline-title  {
  margin-bottom: 0;
  margin-block-end: 0 !important;
}
/* Remove bases header for alias line. */
.bases-embed[src*="Alias line"] .bases-header {
  display: none;
}
.bases-embed[src*="Alias line"] .bases-list-container {
	min-height: 0 !important;
}
.bases-embed[src*="Alias line"] 
:is(
.bases-view,
.bases-list-item
) {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 0 0 0 !important;
    margin: 0 0 0 0 !important;
    transform: translateY(-3px) !important;
}
p:has(span.bases-embed[src*="Alias line"]) {
 margin-bottom: 0 !important;
}

Dataview approach

Insert the following code below the note title (or wherever you’d like the alias line to appear):

dataviewjs
let page = dv.current();

if (page.file.aliases && page.file.aliases.length > 0) {
    dv.el("div", page.file.aliases.join(", "), { 
        cls: "note-alias"
    });
}

I’m also using a custom CSS snippet to style the alias line to my liking:

/* Removing space after note title when followed by alias line. */
.mod-header.mod-ui:has(~ .el-pre .note-alias) .inline-title {
  margin-bottom: 0;
}

/* Custom CSS for the alias line. */
.note-alias {
  font-style: italic;
  font-size: 0.9rem;
  margin-top: -0.2rem;
  margin-bottom: 0.25rem;
}

2 Likes