Browse Source

story: Fixed author/month not showing in menu, reordered menu.

1.0
Gisle Aune 6 years ago
parent
commit
fc5ce3705a
  1. 19
      marko/page/story/components/story-menu/index.marko
  2. 2
      marko/page/story/list.marko
  3. 4
      routes/story/by-month.js

19
marko/page/story/components/story-menu/index.marko

@ -1,22 +1,19 @@
<menu user=input.user> <menu user=input.user>
<menu-header>Story</menu-header> <menu-header>Story</menu-header>
<menu-link key="index" selected=input.selected.index icon="S" href="/story/">Stories</menu-link> <menu-link key="index" selected=input.selected.index icon="S" href="/story/">Stories</menu-link>
<menu-link dark key="_create" on-click("open", "story.add") icon="+">Add Story</menu-link>
<menu-gap />
<menu-header>Categories</menu-header>
<menu-link for(category in (input.categories||[])) key=(category.name) selected=(input.selected.category == category.name) href=("/story/by-category/"+category.name) icon=category.name.charAt(0)>${category.name}</menu-link>
<menu-link selected=input.selected.tags icon="T" href="/story/tag-list/">Tags</menu-link>
<menu-gap /> <menu-gap />
<if(input.menuMonth != null)> <if(input.menuMonth != null)>
<menu-header>Month</menu-header>
<menu-link selected=(input.selected.special === "date") icon="M" href=("/story/by-month/"+input.menuMonth)>${input.menuMonth}</menu-link>
<menu-gap />
<menu-link selected=(input.selected.special === "month") icon="M" href=("/story/by-month/"+input.menuMonth.url)>${input.menuMonth.text}</menu-link>
</if> </if>
<if(input.menuAuthor != null)> <if(input.menuAuthor != null)>
<menu-header>Author</menu-header>
<menu-link selected=(input.selected.special === "author") icon="A" href=("/story/by-author/"+input.menuAuthor)>${input.menuAuthor}</menu-link> <menu-link selected=(input.selected.special === "author") icon="A" href=("/story/by-author/"+input.menuAuthor)>${input.menuAuthor}</menu-link>
<menu-gap />
</if> </if>
<menu-header>Tags</menu-header>
<menu-link for(tag in (input.menuTags||[])) key=(tag.kind+":"+tag.name) selected=(input.selected.tag === tag.kind+":"+tag.name) href=("/story/by-tag/"+tag.kind+"/"+tag.name) textClass=("color-tag-"+tag.kind.toLowerCase()) icon=tag.kind.charAt(0)>${tag.name}</menu-link> <menu-link for(tag in (input.menuTags||[])) key=(tag.kind+":"+tag.name) selected=(input.selected.tag === tag.kind+":"+tag.name) href=("/story/by-tag/"+tag.kind+"/"+tag.name) textClass=("color-tag-"+tag.kind.toLowerCase()) icon=tag.kind.charAt(0)>${tag.name}</menu-link>
<menu-link selected=input.selected.tags icon="T" href="/story/tag-list/">Tags</menu-link>
<menu-gap />
<menu-link dark key="_create" on-click("open", "story.add") icon="+">Add Story</menu-link>
<menu-gap />
<menu-header>Categories</menu-header>
<menu-link for(category in (input.categories||[])) key=(category.name) selected=(input.selected.category == category.name) href=("/story/by-category/"+category.name) icon=category.name.charAt(0)>${category.name}</menu-link>
<menu-gap />
</menu> </menu>

2
marko/page/story/list.marko

@ -1,6 +1,6 @@
<include("../layout", {title: "Stories", site: "story"})> <include("../layout", {title: "Stories", site: "story"})>
<@body> <@body>
<background src="/assets/images/bg.png" opacity=0.25 /> <background src="/assets/images/bg.png" opacity=0.25 />
<page user=input.user stories=input.stories categories=input.categories />
<page user=input.user stories=input.stories categories=input.categories selected=input.selected menuAuthor=input.menuAuthor menuMonth=input.menuMonth />
</@body> </@body>
</include> </include>

4
routes/story/by-month.js

@ -1,3 +1,4 @@
const moment = require("moment")
const express = require("express") const express = require("express")
const router = express.Router() const router = express.Router()
@ -16,11 +17,10 @@ router.get("/:yearmonth(\-{0,1}[0-9]{4}\-[0-9]{1,2})", common, async(req, res) =
// Month is zero-based, while input is one-based. // Month is zero-based, while input is one-based.
const fromDate = new Date(Date.UTC(year, month - 1, 1)) const fromDate = new Date(Date.UTC(year, month - 1, 1))
const toDate = new Date(Date.UTC(year, month, 1)) const toDate = new Date(Date.UTC(year, month, 1))
const monthStr = `${fromDate}-${month > 9 ? month : '0' + month}`
res.markoAsync(listTemplate, { res.markoAsync(listTemplate, {
stories: storyApi.list({earliestFictionalDate: fromDate, latestFictionalDate: toDate}), stories: storyApi.list({earliestFictionalDate: fromDate, latestFictionalDate: toDate}),
menuMonth: monthStr,
menuMonth: {url: moment.utc(fromDate).format("YYYY-MM"), text: moment.utc(fromDate).format("MMMM YYYY")},
selected: {special: "month"}, selected: {special: "month"},
}) })
} catch(err) { } catch(err) {

Loading…
Cancel
Save