#!/bin/bash

# Make the site from template and content.

MARK=.content.html

# merge of template does not work for anything other that current directory
#DIRS=". how-to FAQ"
DIRS="$1"

if [ "$DIRS" = "" ] 
then 
  DIRS="."
  fi
  

FILES=
for d in $DIRS
do
    F="$(echo $d/*$MARK)"
    if [ "$F" != "$d/*$MARK" ]
    then
        FILES="$FILES $(echo $d/*$MARK)"
        fi
    done

if [ "$FILES" = "*$MARK" ]
then
    echo "No content files" 1>&2
    exit 1
    fi

for f in $FILES
do
  html="${f%$MARK}".html
  echo "processing $html" 1>&2
  perl merge $f > $html
  done

