Browse Source

Merge branch 'imp/dynamic-dropdown'

DricomDragon 1 year ago
parent
commit
071a9cf3a5
5 changed files with 16 additions and 23 deletions
  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_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": .}'
 
 # Functions
@@ -37,19 +37,16 @@ extract_update_date = $(shell git log -1 --pretty="format:%cs" $(1))
 build: $(GEN_CONTENT_FILES)
 	$(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 $@ $<
 
-%.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 $@ $<
 
 # Build lists
 $(GEN_LIST_YML): $(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
 .PHONY: install
 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é.
         Certains ont été faits en équipe,
         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,10 +119,12 @@ $if(toc)$
 $endif$
             $^$$body$
 $if(list)$
+$if(display-project-list.full)$
             <div class="card-columns">
                     $^$${ list:card() }
             </div>
 $endif$
+$endif$
         </main>
 $for(include-after)$
         $^$$include-after$

+ 4 - 17
src/templates/navbar.html

@@ -25,26 +25,13 @@
                     Projets
                 </a>
                 <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
                     </a>
+$if(list)$
                     <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>
             </li>
             <li class="nav-item$if(category-contact)$ active$endif$">