Make incoming link list display none if there's nothing
This commit is contained in:
parent
8dd7876ebc
commit
7f78f1db3c
12
calathea.c
12
calathea.c
|
@ -478,17 +478,26 @@ int main(int argc, char *argv[]) {
|
||||||
char *incomingTagStart = strstr(renderedPage, "{{incoming}}");
|
char *incomingTagStart = strstr(renderedPage, "{{incoming}}");
|
||||||
if (incomingTagStart != NULL) {
|
if (incomingTagStart != NULL) {
|
||||||
// Build the incoming links list
|
// Build the incoming links list
|
||||||
int incomingListSize = 37; // <ul class="calathea-incoming">\n</ul>\n
|
// <ul class="calathea-incoming">\n</ul>\n
|
||||||
|
int incomingListSize = 37;
|
||||||
|
if (currentPage->incoming->length == 0) {
|
||||||
|
// ` <li>none</li>\n`
|
||||||
|
incomingListSize += 16;
|
||||||
|
} else {
|
||||||
for (int i = 0; i < currentPage->incoming->length; i++) {
|
for (int i = 0; i < currentPage->incoming->length; i++) {
|
||||||
// ` <li><a href=\"[permalink]\">[title]</a></li>\n`
|
// ` <li><a href=\"[permalink]\">[title]</a></li>\n`
|
||||||
struct Page *page = currentPage->incoming->pages[i];
|
struct Page *page = currentPage->incoming->pages[i];
|
||||||
incomingListSize += 27 + strlen(page->title) + strlen(page->permalink);
|
incomingListSize += 27 + strlen(page->title) + strlen(page->permalink);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *incomingLinksList = malloc((incomingListSize + 1) * sizeof(char));
|
char *incomingLinksList = malloc((incomingListSize + 1) * sizeof(char));
|
||||||
memset(incomingLinksList, 0, (incomingListSize + 1) * sizeof(char));
|
memset(incomingLinksList, 0, (incomingListSize + 1) * sizeof(char));
|
||||||
|
|
||||||
strcpy(incomingLinksList, "<ul class=\"calathea-incoming\">\n");
|
strcpy(incomingLinksList, "<ul class=\"calathea-incoming\">\n");
|
||||||
|
if (currentPage->incoming->length == 0) {
|
||||||
|
strcat(incomingLinksList, " <li>none</li>\n");
|
||||||
|
} else {
|
||||||
for (int i = 0; i < currentPage->incoming->length; i++) {
|
for (int i = 0; i < currentPage->incoming->length; i++) {
|
||||||
struct Page *page = currentPage->incoming->pages[i];
|
struct Page *page = currentPage->incoming->pages[i];
|
||||||
char *link = concat_strings(5,
|
char *link = concat_strings(5,
|
||||||
|
@ -501,6 +510,7 @@ int main(int argc, char *argv[]) {
|
||||||
strcat(incomingLinksList, link);
|
strcat(incomingLinksList, link);
|
||||||
free(link);
|
free(link);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
strcat(incomingLinksList, "</ul>\n");
|
strcat(incomingLinksList, "</ul>\n");
|
||||||
|
|
||||||
char *renderedWithInbound = substitute_string(
|
char *renderedWithInbound = substitute_string(
|
||||||
|
|
Loading…
Reference in New Issue