浏览代码

Merge branch 'imp/dynamic-dropdown'

DricomDragon 2 年之前
父节点
当前提交
071a9cf3a5
共有 5 个文件被更改,包括 16 次插入23 次删除
  1. 3 6
      makefile
  2. 2 0
      src/projets/content.meta.yml
  3. 5 0
      src/templates/item.html
  4. 2 0
      src/templates/main.html
  5. 4 17
      src/templates/navbar.html

+ 3 - 6
makefile

@@ -25,7 +25,7 @@ DIST_FILES := $(DIST_GEN_FILES) $(DIST_INC_FILES) $(DIST_EMB_FILES)
 BUILD_VERSION := $(shell git describe)
 BUILD_VERSION := $(shell git describe)
 BUILD_DATE := $(shell date "+%F")
 BUILD_DATE := $(shell date "+%F")
 
 
-PANDOC_GEN := pandoc --template src/templates/main.html --metadata-file src/meta.yml --metadata=build-date:$(BUILD_DATE) --metadata=build-version:$(BUILD_VERSION) --wrap=none
+PANDOC_GEN := pandoc --template src/templates/main.html --metadata-file src/meta.yml --metadata=build-date:$(BUILD_DATE) --metadata=build-version:$(BUILD_VERSION) --wrap=none --metadata-file $(GEN_LIST_YML)
 LIST_GEN := yq eval-all '{"data": ., "target": {"content": filename | sub("meta.yml", "html") | sub(".*/", ""), "dir": filename | sub("$(DIR_OF_PROJECTS)/", "") | sub("/[^/]*.yml", "")}} as $$item ireduce ([]; . + $$item) | {"list": .}'
 LIST_GEN := yq eval-all '{"data": ., "target": {"content": filename | sub("meta.yml", "html") | sub(".*/", ""), "dir": filename | sub("$(DIR_OF_PROJECTS)/", "") | sub("/[^/]*.yml", "")}} as $$item ireduce ([]; . + $$item) | {"list": .}'
 
 
 # Functions
 # Functions
@@ -37,19 +37,16 @@ extract_update_date = $(shell git log -1 --pretty="format:%cs" $(1))
 build: $(GEN_CONTENT_FILES)
 build: $(GEN_CONTENT_FILES)
 	$(info HTML generated)
 	$(info HTML generated)
 
 
-%.gen.html: %.src.html %.meta.yml $(SRC_TEMPLATES)
+%.gen.html: %.src.html %.meta.yml $(SRC_TEMPLATES) $(GEN_LIST_YML)
 	$(PANDOC_GEN) --metadata-file $*.meta.yml --metadata=category-$(call extract_category,$*) --metadata=update-date:$(call extract_update_date,$<) --output $@ $<
 	$(PANDOC_GEN) --metadata-file $*.meta.yml --metadata=category-$(call extract_category,$*) --metadata=update-date:$(call extract_update_date,$<) --output $@ $<
 
 
-%.gen.html: %.src.md %.meta.yml $(SRC_TEMPLATES)
+%.gen.html: %.src.md %.meta.yml $(SRC_TEMPLATES) $(GEN_LIST_YML)
 	$(PANDOC_GEN) --metadata-file $*.meta.yml --metadata=category-$(call extract_category,$*) --metadata=update-date:$(call extract_update_date,$<) --output $@ $<
 	$(PANDOC_GEN) --metadata-file $*.meta.yml --metadata=category-$(call extract_category,$*) --metadata=update-date:$(call extract_update_date,$<) --output $@ $<
 
 
 # Build lists
 # Build lists
 $(GEN_LIST_YML): $(SRC_LIST_YML)
 $(GEN_LIST_YML): $(SRC_LIST_YML)
 	$(LIST_GEN) $(SRC_LIST_YML) > $@
 	$(LIST_GEN) $(SRC_LIST_YML) > $@
 
 
-$(DIR_OF_PROJECTS)/content.gen.html: $(DIR_OF_PROJECTS)/content.src.html $(DIR_OF_PROJECTS)/content.meta.yml $(GEN_LIST_YML) $(SRC_TEMPLATES)
-	$(PANDOC_GEN) --metadata-file $(DIR_OF_PROJECTS)/content.meta.yml --metadata-file $(GEN_LIST_YML) --metadata=category-projets --metadata=update-date:$(call extract_update_date,$<) --output $@ $<
-
 # Distribution
 # Distribution
 .PHONY: install
 .PHONY: install
 install: $(DIST_DIR)
 install: $(DIST_DIR)

+ 2 - 0
src/projets/content.meta.yml

@@ -9,4 +9,6 @@ content-description:
         Voici l'ensemble des projets de programmation auxquels j'ai participé.
         Voici l'ensemble des projets de programmation auxquels j'ai participé.
         Certains ont été faits en équipe,
         Certains ont été faits en équipe,
         d'autres seuls, certains sont encore en développement.
         d'autres seuls, certains sont encore en développement.
+display-project-list:
+        full: true
 ...
 ...

+ 5 - 0
src/templates/item.html

@@ -0,0 +1,5 @@
+<!-- Project dropdown item component -->
+<a class="dropdown-item"
+   href="/projets/$it.target.dir$/$it.target.content$">
+        $it.data.title$
+</a>

+ 2 - 0
src/templates/main.html

@@ -119,9 +119,11 @@ $if(toc)$
 $endif$
 $endif$
             $^$$body$
             $^$$body$
 $if(list)$
 $if(list)$
+$if(display-project-list.full)$
             <div class="card-columns">
             <div class="card-columns">
                     $^$${ list:card() }
                     $^$${ list:card() }
             </div>
             </div>
+$endif$
 $endif$
 $endif$
         </main>
         </main>
 $for(include-after)$
 $for(include-after)$

+ 4 - 17
src/templates/navbar.html

@@ -25,26 +25,13 @@
                     Projets
                     Projets
                 </a>
                 </a>
                 <div class="dropdown-menu" aria-labelledby="dropdown01">
                 <div class="dropdown-menu" aria-labelledby="dropdown01">
-                    <a class="dropdown-item active" href="/projets/content.html">
+                    <a class="dropdown-item" href="/projets/content.html">
                         Liste des projets
                         Liste des projets
                     </a>
                     </a>
+$if(list)$
                     <div class="dropdown-divider"></div>
                     <div class="dropdown-divider"></div>
-                    <a class="dropdown-item"
-                       href="/projets/static_site/content.html">
-                        Jovian Website
-                    </a>
-                    <a class="dropdown-item"
-                       href="/projets/ascii_space/content.html">
-                        ASCII Space Destroyer
-                    </a>
-                    <a class="dropdown-item"
-                       href="/projets/pulsar/content.html">
-                        Pulsar
-                    </a>
-                    <a class="dropdown-item"
-                       href="/projets/quoridor/content.html">
-                        Quoridor
-                    </a>
+                    $^$${ list:item() }
+$endif$
                 </div>
                 </div>
             </li>
             </li>
             <li class="nav-item$if(category-contact)$ active$endif$">
             <li class="nav-item$if(category-contact)$ active$endif$">